Methods
(static) createBucket(bucketName) → {Object}
- Description:
- Source:
Example
await Qarnot.buckets.createBucket('my-bucket');
Parameters:
Name | Type | Description |
---|---|---|
bucketName |
String | name of the bucket to create |
Returns:
- Type
- Object
(static) deleteBucket(bucketName) → {Promise}
- Description:
- Source:
Example
await Qarnot.buckets.deleteBucket('my-bucket-to-delete');
Parameters:
Name | Type | Description |
---|---|---|
bucketName |
String | name of the bucket to delete |
Returns:
- Type
- Promise
(static) deleteFile() → {Promise}
- Description:
- Delete a file in a bucket see: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/classes/deleteobjectcommand.html
- Source:
Example
await Qarnot.buckets.deleteFile('my-bucket', 'file.txt');
Returns:
- Type
- Promise
(static) download(bucketName, fileName) → {Promise.<Buffer>}
- Description:
- Download content of a file in a bucket
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/classes/getobjectcommand.html
- Download content of a file in a bucket
- Source:
Examples
const data = await Qarnot.buckets.download('my-bucket', 'file.txt', params);
console.log(data)
console.log(data.Body.toString())
{
AcceptRanges: 'bytes',
LastModified: 2019-06-11T20:13:17.000Z,
ContentLength: 11,
ETag: '"5eb63bbbe01eeed093cb22bb8f5acdc3"',
ContentType: 'application/octet-stream',
Metadata: {},
Body: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
}
hello world
Parameters:
Name | Type | Description |
---|---|---|
bucketName |
String | name of the bucket |
fileName |
String | name of the file to create |
Returns:
File info and content
More info see: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/getobjectcommandoutput.html
More info see: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/getobjectcommandoutput.html
- Type
- Promise.<Buffer>
(static) listBuckets() → {Object}
- Description:
- Source:
Examples
const buckets = await Qarnot.buckets.listBuckets();
console.log(buckets);
{
Buckets: [
{ Name: 'my-bucket', CreationDate: 2019-06-11T12:59:43.743Z }
],
Owner: { DisplayName: 'john.doe', ID: 'xx$xx' }
}
Returns:
List of all buckets
- Type
- Object
(static) listFiles(bucketName, paramsopt) → {Promise.<Object>}
- Description:
- List all files in a bucket
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/classes/listobjectsv2command.html
- List all files in a bucket
- Source:
Examples
const files = await Qarnot.buckets.listFiles('my-bucket');
console.log(files);
{
Contents: [
{
Key: 'test.txt',
LastModified: 2023-05-30T09:30:53.873Z,
ETag: '"f7482490035aa20e0bed1375d44e97bf"',
Size: 17,
StorageClass: 'STANDARD'
}
],
IsTruncated: false,
KeyCount: 1,
MaxKeys: 1000,
Name: 'test-suite-nodejs',
Prefix: ''
}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
bucketName |
String | name of the bucket | |
params |
Object |
<optional> |
custom params object for the storage API (see code and aws s3 sdk documentation) |
Returns:
Files in your bucket
- Type
- Promise.<Object>
(static) upload(bucketName, fileName, data) → {Promise.<Object>}
- Description:
- Upload data in a bucket
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_lib_storage.html
- Upload data in a bucket
- Source:
Examples
const file = await Qarnot.buckets.upload('my-bucket', 'file.txt', data, mimetype);
console.log(file);
{
ETag: '"f7482490035aa20e0bed1375d44e97bf"',
Bucket: 'test-suite-nodejs',
Key: 'test.txt',
Location: 'https://test-suite-nodejs.storage.qarnot.com/test.txt'
}
Parameters:
Name | Type | Description |
---|---|---|
bucketName |
String | name of the bucket |
fileName |
String | name of the file to create |
data |
Buffer | ReadableStream | String | data to upload |
Returns:
Object describing the created file
- Type
- Promise.<Object>