new AWSClientS3(config)
Parameters:
| Name | Type | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
object | AWSClientS3 configuration options Properties
|
- Source:
Throws:
Will throw an Error if required arguments are missing
Methods
(async) createBucket(bucketName, bucketOptionsopt) → {Promise.<CreateBucketCommandOutput>}
Creates bucket with bucketName - If bucketOptions passed, these will override default options
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
bucketName |
string | Name of new bucket |
||
bucketOptions |
object |
<optional> |
null | Bucket options as defined by the AWS S3 SDK docs |
- Source:
Throws:
Will throw an Error if required arguments are missing
Returns:
- Type
- Promise.<CreateBucketCommandOutput>
(async) deleteBucket(bucketName) → {Promise.<DeleteBucketCommandOutput>}
Deletes specified bucket
Parameters:
| Name | Type | Description |
|---|---|---|
bucketName |
string | Name of bucket to delete |
- Source:
Throws:
Will throw an Error if specified bucket is Versioning Enabled
Returns:
- Type
- Promise.<DeleteBucketCommandOutput>
(async) deleteFile(objectParams) → {Promise.<DeleteObjectCommandOutput>}
Deletes specified file from S3 bucket at specified key
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
objectParams |
object |
Properties
|
- Source:
Throws:
Will throw an Error if required arguments are missing
Returns:
- Type
- Promise.<DeleteObjectCommandOutput>
(async) getPresignedUrl(objectParams, presignedUrlOptionsopt) → {Promise.<string>}
Returns pre-signed URL for specific S3 object
Parameters:
| Name | Type | Attributes | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
objectParams |
object | Target object's location data (bucket and key) Properties
|
||||||||||
presignedUrlOptions |
object |
<optional> |
Config options for resultant pre-signed URL |
- Source:
Throws:
Will throw an Error if required arguments are missing
Returns:
Promise which resolves to the pre-sgiend URL for the requested object
- Type
- Promise.<string>
(async) listBucketObjects(bucketName, prefixopt) → {Promise.<ListObjectsV2CommandOutput>}
List objects of specified bucket with specified prefix (or all bucket objects if no prefix specified)
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
bucketName |
string | |||
prefix |
string |
<optional> |
null |
- Source:
Throws:
Will throw an Error if required arguments are missing or not of expected type
Returns:
- Type
- Promise.<ListObjectsV2CommandOutput>
(async) listBuckets() → {Promise.<ListBucketsCommandOutput>}
Lists all buckets
- Source:
Returns:
- Type
- Promise.<ListBucketsCommandOutput>
(async) readFile(objectParams, returnTypeopt) → {Promise.<(ReadableStream|Buffer|string)>}
Returns contents of specified S3 object
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
objectParams |
object | Target object's location data (bucket and key) Properties
|
|||||||||||
returnType |
string |
<optional> |
stream | Return type for requested S3 object |
- Source:
Throws:
Will throw an Error if required arguments are missing
Returns:
Promise which resolves to the requested file's contents as the specified data type
- Type
- Promise.<(ReadableStream|Buffer|string)>
(async) uploadFile(file, objectParams) → {Promise.<PutObjectCommandOutput>}
Uploads file object to specified S3 bucket and key destination
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
file |
Buffer | File-to-upload as Buffer |
|||||||||
objectParams |
object | File-to-upload destination data (bucket and key) Properties
|
- Source:
Throws:
Will throw an Error if required arguments are missing or not of expected type
Returns:
- Type
- Promise.<PutObjectCommandOutput>