@ukab/storage-s3-adapter
v0.2.4
Published
Ukab Ecosystem storage
Downloads
6
Maintainers
Readme
Ukab Storage S3 Adapter
The library is compitable with both ESM and CommonJS.
Usage
const ukab = require('@ukab/storage');
const s3Adapter = require('@ukab/storage-s3-adapter');
const config = {
defaultAdapter: 'myS3',
basedir: 'relative/path/to/storage',
acl: {
public: { dir: 'open' },
private: { dir: 'closed' },
},
s3: {
bucket: 'mybucket'
},
};
const drivers = new ukab.StorageDrivers();
drivers.set('myDisk', new ukab.DiskAdapter(config));
drivers.set('myS3', new s3Adapter.S3Adapter(config));
const storage = ukab.storage('custom', config, drivers);
storage.save({
file: request.file,
folder: 'optional',
});
Create scoped storage with its own drivers, You are free to share drivers between isolated storages if you want or required.
const ukab = require('@ukab/storage');
const s3Adapter = require('@ukab/storage-s3-adapter');
const config = {
defaultAdapter: 'otherS3',
basedir: 'relative/path/to/storage',
acl: {
public: { dir: 'public' },
private: { dir: 'private' },
},
s3: {
bucket: 'mybucket'
},
};
const drivers = new ukab.StorageDrivers();
drivers.set('otherS3', new s3Adapter.S3Adapter(config));
const storage = ukab.storage('other', config, drivers);
storage.save({
file: request.file,
folder: 'optional',
});