diff --git a/demo/adapter-local.js b/demo/adapter-local.js index 95a05a5..148694d 100644 --- a/demo/adapter-local.js +++ b/demo/adapter-local.js @@ -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) } diff --git a/demo/adapter-s3-backblazejs b/demo/adapter-s3-backblazejs index f8793cb..5f32b2a 100644 --- a/demo/adapter-s3-backblazejs +++ b/demo/adapter-s3-backblazejs @@ -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) } diff --git a/demo/adapter-s3-hetzner.js b/demo/adapter-s3-hetzner.js index 2a601cb..dce770a 100644 --- a/demo/adapter-s3-hetzner.js +++ b/demo/adapter-s3-hetzner.js @@ -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) } diff --git a/demo/local-development.js b/demo/local-development.js index 710926e..73c1e9b 100644 --- a/demo/local-development.js +++ b/demo/local-development.js @@ -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) diff --git a/readme.md b/readme.md index b393435..ea228d6 100644 --- a/readme.md +++ b/readme.md @@ -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) } @@ -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. @@ -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. @@ -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) diff --git a/src/storage-adapter-local/docs/ReadFunctionOpts.md b/src/storage-adapter-local/docs/ReadFunctionOpts.md index 86a48a8..b2b43a5 100644 --- a/src/storage-adapter-local/docs/ReadFunctionOpts.md +++ b/src/storage-adapter-local/docs/ReadFunctionOpts.md @@ -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). diff --git a/src/storage-adapter-local/docs/WriteFunctionOpts.md b/src/storage-adapter-local/docs/WriteFunctionOpts.md index 17f2ecf..60e17ae 100644 --- a/src/storage-adapter-local/docs/WriteFunctionOpts.md +++ b/src/storage-adapter-local/docs/WriteFunctionOpts.md @@ -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). diff --git a/src/storage-adapter-local/package-lock.json b/src/storage-adapter-local/package-lock.json index e6561f3..ddec570 100644 --- a/src/storage-adapter-local/package-lock.json +++ b/src/storage-adapter-local/package-lock.json @@ -1,12 +1,12 @@ { "name": "@brighter/storage-adapter-local", - "version": "1.6.0", + "version": "1.6.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@brighter/storage-adapter-local", - "version": "1.6.0", + "version": "1.6.1", "license": "MIT", "dependencies": { "@brighter/storage": "*" diff --git a/src/storage-adapter-s3/docs/ReadFunctionOpts.md b/src/storage-adapter-s3/docs/ReadFunctionOpts.md index 86a48a8..b2b43a5 100644 --- a/src/storage-adapter-s3/docs/ReadFunctionOpts.md +++ b/src/storage-adapter-s3/docs/ReadFunctionOpts.md @@ -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). diff --git a/src/storage-adapter-s3/docs/WriteFunctionOpts.md b/src/storage-adapter-s3/docs/WriteFunctionOpts.md index 17f2ecf..60e17ae 100644 --- a/src/storage-adapter-s3/docs/WriteFunctionOpts.md +++ b/src/storage-adapter-s3/docs/WriteFunctionOpts.md @@ -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). diff --git a/src/storage-adapter-s3/package-lock.json b/src/storage-adapter-s3/package-lock.json index 3930c05..ffe39c4 100644 --- a/src/storage-adapter-s3/package-lock.json +++ b/src/storage-adapter-s3/package-lock.json @@ -1,12 +1,12 @@ { "name": "@brighter/storage-adapter-s3", - "version": "1.6.0", + "version": "1.6.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@brighter/storage-adapter-s3", - "version": "1.6.0", + "version": "1.6.1", "license": "MIT", "dependencies": { "@aws-sdk/client-s3": "^3.744.0", diff --git a/src/storage/docs/Config.md b/src/storage/docs/Config.md index 9e0be8a..2e624ab 100644 --- a/src/storage/docs/Config.md +++ b/src/storage/docs/Config.md @@ -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). diff --git a/src/storage/docs/ReadFunctionOpts.md b/src/storage/docs/ReadFunctionOpts.md index 86a48a8..b2b43a5 100644 --- a/src/storage/docs/ReadFunctionOpts.md +++ b/src/storage/docs/ReadFunctionOpts.md @@ -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). diff --git a/src/storage/docs/WriteFunctionOpts.md b/src/storage/docs/WriteFunctionOpts.md index 17f2ecf..60e17ae 100644 --- a/src/storage/docs/WriteFunctionOpts.md +++ b/src/storage/docs/WriteFunctionOpts.md @@ -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). diff --git a/src/storage/package-lock.json b/src/storage/package-lock.json index 7c4666a..8905258 100644 --- a/src/storage/package-lock.json +++ b/src/storage/package-lock.json @@ -1,12 +1,12 @@ { "name": "@brighter/storage", - "version": "1.6.0", + "version": "1.6.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@brighter/storage", - "version": "1.6.0", + "version": "1.6.1", "license": "MIT", "dependencies": { "iconv-lite": "^0.6.3", diff --git a/src/storage/src/index.d.ts b/src/storage/src/index.d.ts index 9c03fba..121a1e7 100644 --- a/src/storage/src/index.d.ts +++ b/src/storage/src/index.d.ts @@ -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 @@ -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 } @@ -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 } diff --git a/src/storage/src/tests/copy.test.js b/src/storage/src/tests/copy.test.js index 8e451b3..16de450 100644 --- a/src/storage/src/tests/copy.test.js +++ b/src/storage/src/tests/copy.test.js @@ -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') ]) @@ -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') @@ -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') @@ -100,7 +100,7 @@ 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` @@ -108,32 +108,32 @@ const run = provider => { }) 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') }) @@ -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 }) })