An aws s3 sdk wrapper as a service for the moleculer framework. The project is based on the moleculer-minio project and is intended as a drop in replacement if you feel the need to use version 3 of the aws s3 sdk.
The following List details which features are implemented
- Bucket Management (Create, Delete, List)
- Object Management (Put, List, Delete, Stat)
- Presigned URL Management (Generate presigned URLs and Post Policy signed URLs)
npm install moleculer-aws-s3 --save
Property | Type | Default | Description |
---|---|---|---|
endPoint |
String |
required | The Hostname s3 is running on and available at. Hostname or IP-Address |
port |
Number |
required | TCP/IP port number s3 is listening on. Default value set to 80 for HTTP and 443 for HTTPs. |
useSSL |
Boolean |
null |
If set to true, https is used instead of http. Default is true. |
accessKey |
String |
required | The AccessKey to use when connecting to s3 |
secretKey |
String |
required | The SecretKey to use when connecting to s3 |
region |
String |
required | Set this value to override region cache |
sessionToken |
String |
null |
Set this value to provide x-amz-security-token (AWS S3 specific). (Optional) |
s3HealthCheckInterval |
Number |
null |
This service will perform a periodic healthcheck of s3. Use this setting to configure the inverval in which the healthcheck is performed. Set to 0 to turn healthcheks of |
s3ForcePathStyle |
Boolean |
null |
If set to true, path style is used instead of virtual host style. Default is false. |
endPointIsString |
Boolean |
null |
If set to true, the endpoint is set as is. Default is false. |
Creates a new Bucket
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | The name of the bucket |
region |
string |
required | The region to create the bucket in. Defaults to "us-east-1" |
Type: PromiseLike.<(undefined|Error)>
Lists all buckets.
Property | Type | Default | Description |
---|---|---|---|
No input parameters. |
Type: PromiseLike.<(Array.<Bucket>|Error)>
Checks if a bucket exists.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket |
Type: PromiseLike.<(boolean|Error)>
Removes a bucket.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket |
Type: PromiseLike.<(boolean|Error)>
Lists all objects in a bucket.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket |
prefix |
string |
required | The prefix of the objects that should be listed (optional, default ''). |
recursive |
boolean |
required | true indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default false ). |
Type: PromiseLike.<(Array.<Object>|Error)>
Lists all objects in a bucket using S3 listing objects V2 API
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket |
prefix |
string |
required | The prefix of the objects that should be listed (optional, default ''). |
recursive |
boolean |
required | true indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default false ). |
startAfter |
string |
required | Specifies the object name to start after when listing objects in a bucket. (optional, default ''). |
Type: PromiseLike.<(Array.<Object>|Error)>
Lists partially uploaded objects in a bucket.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket |
prefix |
string |
required | The prefix of the objects that should be listed (optional, default ''). |
recursive |
boolean |
required | true indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default false ). |
Type: PromiseLike.<(Array.<Object>|Error)>
Downloads an object as a stream.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket |
objectName |
string |
required | Name of the object. |
Type: PromiseLike.<(ReadableStream|Error)>
Downloads the specified range bytes of an object as a stream.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket. |
objectName |
string |
required | Name of the object. |
offset |
number |
required | offset of the object from where the stream will start. |
length |
number |
required | length of the object that will be read in the stream (optional, if not specified we read the rest of the file from the offset). |
Type: PromiseLike.<(ReadableStream|Error)>
Downloads and saves the object as a file in the local filesystem.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket. |
objectName |
string |
required | Name of the object. |
filePath |
string |
required | Path on the local filesystem to which the object data will be written. |
Type: PromiseLike.<(undefined|Error)>
Uploads an object from a stream/Buffer.
Property | Type | Default | Description |
---|---|---|---|
params |
ReadableStream |
required | Readable stream. |
bucketName |
string |
required | Name of the bucket. |
objectName |
string |
required | Name of the object. |
size |
number |
required | Size of the object (optional). |
metaData |
object |
required | metaData of the object (optional). |
Type: PromiseLike.<(undefined|Error)>
Uploads contents from a file to objectName.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket. |
objectName |
string |
required | Name of the object. |
filePath |
string |
required | Path of the file to be uploaded. |
metaData |
object |
required | metaData of the object (optional). |
Type: PromiseLike.<(undefined|Error)>
Copy a source object into a new object in the specified bucket.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket. |
objectName |
string |
required | Name of the object. |
sourceObject |
string |
required | Path of the file to be copied. |
conditions |
object |
required | Conditions to be satisfied before allowing object copy. |
metaData |
object |
required | metaData of the object (optional). |
Type: PromiseLike.<({etag: {string}, lastModified: {string}}|Error)>
Gets metadata of an object.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket. |
objectName |
string |
required | Name of the object. |
Type: PromiseLike.<({size: {number}, metaData: {object}, lastModified: {string}, etag: {string}}|Error)>
Removes an Object
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket. |
objectName |
string |
required | Name of the object. |
Type: PromiseLike.<(undefined|Error)>
Removes a list of Objects
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket. |
objectNames |
Array.<string> |
required | Names of the objects. |
Type: PromiseLike.<(undefined|Error)>
Removes a partially uploaded object.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket. |
objectName |
string |
required | Name of the object. |
Type: PromiseLike.<(undefined|Error)>
Generates a presigned URL for HTTP GET operations. Browsers/Mobile clients may point to this URL to directly download objects even if the bucket is private. This presigned URL can have an associated expiration time in seconds after which the URL is no longer valid. The default value is 7 days.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket. |
objectName |
string |
required | Name of the object. |
expires |
number |
required | Expiry time in seconds. Default value is 7 days. (optional) |
reqParams |
object |
required | request parameters. (optional) |
requestDate |
string |
required | An ISO date string, the url will be issued at. Default value is now. (optional) |
Type: PromiseLike.<(String|Error)>
Generates a presigned URL for HTTP PUT operations. Browsers/Mobile clients may point to this URL to upload objects directly to a bucket even if it is private. This presigned URL can have an associated expiration time in seconds after which the URL is no longer valid. The default value is 7 days.
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Name of the bucket. |
objectName |
string |
required | Name of the object. |
expires |
number |
required | Expiry time in seconds. Default value is 7 days. (optional) |
Type: PromiseLike.<(String|Error)>
Creates and returns a new S3 client
Property | Type | Default | Description |
---|---|---|---|
No input parameters. |
Type: Client
Pings the configured S3 backend
Property | Type | Default | Description |
---|---|---|---|
timeout |
number |
required | Amount of miliseconds to wait for a ping response |
Type: PromiseLike.<(boolean|S3PingError)>
Gets a list of incomplete uploads
Property | Type | Default | Description |
---|---|---|---|
bucketName |
string |
required | Amount of miliseconds to wait for a ping response |
prefix |
string |
required | Amount of miliseconds to wait for a ping response |
keyMarker |
string |
required | Amount of miliseconds to wait for a ping response |
uploadIdMarker |
string |
required | Amount of miliseconds to wait for a ping response |
delimiter |
string |
required | Amount of miliseconds to wait for a ping response |
Type: PromiseLike.<Array.<Object>>
$ npm test
In development with watching
$ npm run ci
Please send pull requests improving the usage and fixing bugs, improving documentation and providing better examples, or providing some testing, because these things are important.
The project is available under the MIT license.
Copyright (c) 2021 Kenneth Shepherd