https://github.com/akofman/node-s3-extra
Convenient extra methods for the AWS.S3 service.
https://github.com/akofman/node-s3-extra
aws getobjectstream nodejs s3 upload
Last synced: about 1 year ago
JSON representation
Convenient extra methods for the AWS.S3 service.
- Host: GitHub
- URL: https://github.com/akofman/node-s3-extra
- Owner: akofman
- License: mit
- Created: 2019-01-16T15:23:04.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2023-01-06T19:00:09.000Z (over 3 years ago)
- Last Synced: 2025-04-23T03:49:06.014Z (about 1 year ago)
- Topics: aws, getobjectstream, nodejs, s3, upload
- Language: JavaScript
- Homepage:
- Size: 2.85 MB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-s3-extra [](https://travis-ci.org/akofman/node-s3-extra)
> Convenient extra methods for the AWS.S3 service.
## Install
$ npm install s3-extra
## Usage
```js
const s3 = require('s3-extra')({ uploadConcurrency: 50 });
// original s3 api services are still reachable
var params = { Bucket: 'bucket', Key: 'key', Body: stream };
s3.putObject(params, (err, data) => {
console.log(err, data);
});
// plus some extra methods
try {
// retrieve an S3 object stream from its url
const objStream = s3.getObjectStream('s3://my-bucket/my/object/filename');
// upload a folder and keep the same hierarchy
await s3.uploadFileOrFolder('my/local/folder/path/', 's3://my-bucket/path/', {
ACL: 'public-read'
});
// or just upload a file
await s3.uploadFileOrFolder(
'my/local/folder/path/file.txt',
's3://my-bucket/path/'
);
} catch (err) {
throw err;
}
```
## API
#### Table of Contents
- [getObjectStream](#getobjectstream)
- [Parameters](#parameters)
- [uploadFileOrFolder](#uploadfileorfolder)
- [Parameters](#parameters-1)
### getObjectStream
Retrieves objects from Amazon S3.
#### Parameters
- `s3Url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a valid s3 url reprensenting the location of the object to get.
- `params` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the same params as the AWS [getObject](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getObject-property) method are accepted. (optional, default `{}`)
Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** a stream object.
### uploadFileOrFolder
Uploads a file or a folder to an Amazon S3 bucket.
#### Parameters
- `contentPath` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path to a file or a folder to upload.
- `s3Url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a valid s3 url representing the location to put the content.
- `params` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the same params as the AWS [upload](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property) method are accepted. (optional, default `{}`)
Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** a promise.
## License
MIT Licensed. Copyright (c) Alexis Kofman 2019.