Methods
(static) createBucket(bucketName) → {Promise}
Create a new bucket
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#createBucket-property
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#createBucket-property
Example
Usage
await Qarnot.buckets.createBucket('my-bucket');
Parameters:
Name | Type | Description |
---|---|---|
bucketName |
String | name of the bucket to create |
Returns:
- Type
- Promise
(static) deleteBucket(bucketName) → {Promise}
Delete a bucket
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#deleteBucket-property
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#deleteBucket-property
Example
Usage
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}
Delete a file in a bucket
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#deleteObject-property
Example
await Qarnot.buckets.deleteFile('my-bucket', 'file.txt');
Returns:
- Type
- Promise
(static) download(bucketName, fileName) → {Promise.<Buffer>}
Download content of a file in a bucket
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#download-property
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#download-property
Examples
Usage
const data = await Qarnot.buckets.download('my-bucket', 'file.txt', params);
console.log(data)
console.log(data.Body.toString())
Output
{
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
- Type
- Promise.<Buffer>
(static) listBuckets() → {Promise.<Object>}
List all buckets
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#listBuckets-property
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#listBuckets-property
Examples
Usage
const buckets = await Qarnot.buckets.listBuckets();
console.log(buckets);
Output
{
Buckets: [
{ Name: 'my-bucket', CreationDate: 2019-06-11T12:59:43.743Z }
],
Owner: { DisplayName: 'john.doe', ID: 'xx$xx' }
}
Returns:
List of all buckets
- Type
- Promise.<Object>
(static) listFiles(bucketName, paramsopt) → {Promise.<Object>}
List all files in a bucket
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#listObjectsV2-property
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#listObjectsV2-property
Examples
Usage
const files = await Qarnot.buckets.listFiles('my-bucket');
console.log(files);
Output
{
IsTruncated: false,
Contents: [{
Key: 'file.txt',
LastModified: 2019-06-11T20:13:17.862Z,
ETag: '"5eb63bbbe01eeed093cb22bb8f5acdc3"',
Size: 11,
StorageClass: 'STANDARD',
Owner: [Object]
}],
Name: 'my-bucket',
Prefix: '',
MaxKeys: 1000,
CommonPrefixes: []
}
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>}
Upload data in a bucket
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property
see: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property
Examples
Usage
const file = await Qarnot.buckets.upload('my-bucket', 'file.txt', data);
console.log(file);
Output
{
ETag: '"5eb63bbbe01eeed093cb22bb8f5acdc3"',
Location: 'https://my-bucket.storage.qarnot.com/file.txt',
key: 'file.txt',
Key: 'file.txt',
Bucket: 'my-bucket'
}
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>