Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo/adapter-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Storage } from '@brighter/storage-adapter-local'
const storage = Storage({ path: '/tmp/storage' })

const main = async () => {
await storage.write('msg.txt', 'hello')
const msg = await storage.read('msg.txt')
await storage.write('file', 'hello')
const msg = await storage.read('file')
console.log(msg)
}

Expand Down
4 changes: 2 additions & 2 deletions demo/adapter-s3-backblazejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const storage = Storage({
})

const main = async () => {
await storage.write('info.log', 'hi')
const msg = await storage.read('info.log')
await storage.write('file', 'hi')
const msg = await storage.read('file')
console.log(msg)
}

Expand Down
4 changes: 2 additions & 2 deletions demo/adapter-s3-hetzner.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const storage = Storage({
})

const main = async () => {
await storage.write('info.log', 'hi')
const msg = await storage.read('info.log')
await storage.write('file', 'hi')
const msg = await storage.read('file')
console.log(msg)
}

Expand Down
2 changes: 1 addition & 1 deletion demo/local-development.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const createStorage = () => {

const main = async () => {
const storage = createStorage()
await storage.read('info.log')
await storage.read('file')
}

main().catch(console.error)
28 changes: 14 additions & 14 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import { Storage } from '@brighter/storage-adapter-s3'
const storage = Storage({ path: 'my-bucket' }, { region: 'eu-central-1' })

const main = async () => {
await storage.write('info.log', 'hello')
const msg = await storage.read('info.log')
await storage.write('file', 'hello')
const msg = await storage.read('file')
console.log(msg)
}

Expand All @@ -62,14 +62,14 @@ For more information:
Here's a quick API overview:

```js
await storage.read('info.log')
await storage.write('info.log', 'hello')
await storage.remove('info.log')
await storage.exists('info.log')
await storage.stat('info.log')
await storage.copy('info.log', 'info.copy.log')
await storage.list('/')
await storage.presign('info.log')
await storage.read(file)
await storage.write(file, fileContents)
await storage.remove(fileOrDir)
await storage.exists(fileOrDir)
await storage.stat(file)
await storage.copy(fileOrDir, fileOrDir)
await storage.list(dir)
await storage.presign(file)
```

See [StorageInterface](src/storage/docs/StorageInterface.md) for more information.
Expand All @@ -91,9 +91,9 @@ See the [ReadFunction](src/storage/docs/ReadFunction.md) for more information.
To write data to object storage, use the `write()` function, specifying the desired file path as the first argument, the content to write (which can be a `string` or a `Buffer`) as the second, and optionally an encoding option like `utf8` or `binary` in the third argument.

```js
await storage.write('msg.txt', 'hello')
await storage.write('msg.txt', 'Ω', { encoding: 'utf8' })
await storage.write('msg.txt', Buffer.alloc(4), { encoding: 'binary' })
await storage.write('file', 'hello')
await storage.write('file', 'Ω', { encoding: 'utf8' })
await storage.write('file', Buffer.alloc(4), { encoding: 'binary' })
```
See the [WriteFunction](src/storage/docs/WriteFunction.md) for more information.

Expand Down Expand Up @@ -183,7 +183,7 @@ const createStorage = () => {

const main = async () => {
const storage = createStorage()
await storage.read('info.log')
await storage.read('file')
}

main().catch(console.error)
Expand Down
2 changes: 1 addition & 1 deletion src/storage-adapter-local/docs/ReadFunctionOpts.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Properties:

#### encoding: string

File encoding. Optional, default is `utf8`.
File encoding. Optional, default is `utf8`. See [list of supported encodings](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).



Expand Down
2 changes: 1 addition & 1 deletion src/storage-adapter-local/docs/WriteFunctionOpts.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Properties:

#### encoding: string

File encoding. Optional, default is `utf8`.
File encoding. Optional, default is `utf8`. See [list of supported encodings](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).



Expand Down
4 changes: 2 additions & 2 deletions src/storage-adapter-local/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/storage-adapter-s3/docs/ReadFunctionOpts.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Properties:

#### encoding: string

File encoding. Optional, default is `utf8`.
File encoding. Optional, default is `utf8`. See [list of supported encodings](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).



Expand Down
2 changes: 1 addition & 1 deletion src/storage-adapter-s3/docs/WriteFunctionOpts.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Properties:

#### encoding: string

File encoding. Optional, default is `utf8`.
File encoding. Optional, default is `utf8`. See [list of supported encodings](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).



Expand Down
4 changes: 2 additions & 2 deletions src/storage-adapter-s3/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/storage/docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Storage root path. For example `/tmp/storage`.

#### encoding: string

File encoding. Optional, default is `utf8`.
File encoding. Optional, default is `utf8`. See [list of supported encodings](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).



Expand Down
2 changes: 1 addition & 1 deletion src/storage/docs/ReadFunctionOpts.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Properties:

#### encoding: string

File encoding. Optional, default is `utf8`.
File encoding. Optional, default is `utf8`. See [list of supported encodings](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).



Expand Down
2 changes: 1 addition & 1 deletion src/storage/docs/WriteFunctionOpts.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Properties:

#### encoding: string

File encoding. Optional, default is `utf8`.
File encoding. Optional, default is `utf8`. See [list of supported encodings](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).



Expand Down
4 changes: 2 additions & 2 deletions src/storage/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/storage/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Config = {
path: string

/**
* File encoding. Optional, default is `utf8`.
* File encoding. Optional, default is `utf8`. See [list of supported encodings](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).
*/
encoding?: string

Expand Down Expand Up @@ -191,7 +191,7 @@ type PreSignFunction = {
*/
type ReadFunctionOpts = {
/**
* File encoding. Optional, default is `utf8`.
* File encoding. Optional, default is `utf8`. See [list of supported encodings](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).
*/
encoding?: string
}
Expand Down Expand Up @@ -324,7 +324,7 @@ type StatFunction = {
*/
type WriteFunctionOpts = {
/**
* File encoding. Optional, default is `utf8`.
* File encoding. Optional, default is `utf8`. See [list of supported encodings](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).
*/
encoding?: string
}
Expand Down
22 changes: 11 additions & 11 deletions src/storage/src/tests/copy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const run = provider => {
storage = global._storage.getStorage(provider)
await storage.remove('/')
await Promise.all([
storage.write('msg.txt', 'hi'),
storage.write('file', 'hi'),
storage.write('sub/one', 'hi'),
storage.write('sub/sub/one', 'hi')
])
Expand Down Expand Up @@ -73,7 +73,7 @@ const run = provider => {

it(`should throw when pathFrom is out of scope`, async () => {
const err = await storage
.copy('../../msg.txt', 'msg_copy.txt')
.copy('../../file', 'msg_copy.txt')
.catch(err => err)

expect(err).to.be.an('error')
Expand All @@ -83,7 +83,7 @@ const run = provider => {

it(`should throw when pathTo is out of scope`, async () => {
const err = await storage
.copy('msg.txt', '../../msg_copy.txt')
.copy('file', '../../msg_copy.txt')
.catch(err => err)

expect(err).to.be.an('error')
Expand All @@ -100,40 +100,40 @@ const run = provider => {
})

it(`should throw when 'pathFrom' is a directory and 'pathTo' a file`, async () => {
const err = await storage.copy('nope/', 'msg.txt').catch(err => err)
const err = await storage.copy('nope/', 'file').catch(err => err)
expect(err).to.be.an('error')
expect(err.message).to.eql(
`Unable to copy, 'pathFrom' is a directory and 'pathTo' a file`
)
})

it('should copy, file to file', async () => {
await storage.copy('msg.txt', 'msg_copy.txt')
await storage.copy('file', 'msg_copy.txt')
const result = await storage.read('msg_copy.txt')
expect(result).to.eql('hi')
})

it('should resolve and copy, file to file #1', async () => {
await storage.copy('foo/../msg.txt', 'msg_copy1.txt')
await storage.copy('foo/../file', 'msg_copy1.txt')
const result = await storage.read('msg_copy1.txt')
expect(result).to.eql('hi')
})

it('should resolve and copy, file to file #2', async () => {
await storage.copy('msg.txt', 'foo/../msg_copy2.txt')
await storage.copy('file', 'foo/../msg_copy2.txt')
const result = await storage.read('msg_copy2.txt')
expect(result).to.eql('hi')
})

it('should copy, file to file inside a subfolder', async () => {
await storage.copy('msg.txt', 'copy/msg_copy.txt')
await storage.copy('file', 'copy/msg_copy.txt')
const result = await storage.read('copy/msg_copy.txt')
expect(result).to.eql('hi')
})

it('should copy, file to folder #1', async () => {
await storage.copy('msg.txt', 'copy/')
const result = await storage.read('copy/msg.txt')
await storage.copy('file', 'copy/')
const result = await storage.read('copy/file')
expect(result).to.eql('hi')
})

Expand All @@ -160,7 +160,7 @@ const run = provider => {

describe('output', () => {
it('should return undefined', async () => {
const result = await storage.copy('msg.txt', 'msg_copy.txt')
const result = await storage.copy('file', 'msg_copy.txt')
expect(result).to.be.undefined
})
})
Expand Down