0.3.0 • Published 4 months ago

barnard59-s3 v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

barnard59-s3

Add support for S3 to barnard59.

Working with files

getObject

Get an object from a S3 bucket into the file system.

OptionTypeRequiredDescription
bucketstringtrueThe name of the S3 bucket
keystringtrueThe key of the object
destinationPathstringtrueThe path where the object should be downloaded. If the directory that contains the path do not exist, it will be created.
accessKeyIdstringfalseS3 Access Key ID
secretAccessKeystringfalseS3 Secret Access Key

And all options from S3ClientConfigType of the AWS SDK, which includes those fields for example:

  • endpoint (type: string ; configure a custom endpoint)
  • region (type: string ; defaults to us-east-1 if not specified)
  • forcePathStyle (type: boolean; set to true if you want to use a custom endpoint)

putObject

Put an object from the file system into a S3 bucket.

OptionTypeRequiredDescription
bucketstringtrueThe name of the S3 bucket
keystringtrueThe key of the object
sourcePathstringtrueThe path of the file on the local file system
accessKeyIdstringfalseS3 Access Key ID
secretAccessKeystringfalseS3 Secret Access Key

And all options from S3ClientConfigType of the AWS SDK, which includes those fields for example:

  • endpoint (type: string ; configure a custom endpoint)
  • region (type: string ; defaults to us-east-1 if not specified)
  • forcePathStyle (type: boolean; set to true if you want to use a custom endpoint)

Working with streams

getObjectStream (getObject/stream operation)

Get an object from a S3 bucket as a Readable stream.

OptionTypeRequiredDescription
bucketstringtrueThe name of the S3 bucket
keystringtrueThe key of the object
accessKeyIdstringfalseS3 Access Key ID
secretAccessKeystringfalseS3 Secret Access Key

And all options from S3ClientConfigType of the AWS SDK, which includes those fields for example:

  • endpoint (type: string ; configure a custom endpoint)
  • region (type: string ; defaults to us-east-1 if not specified)
  • forcePathStyle (type: boolean; set to true if you want to use a custom endpoint)

This returns a Readable stream that contains the content of the requested object.

Upload data to S3

To put a stream into a S3 bucket, you will need to first write the stream to a file and then use putObject to upload the file to S3.

Direct stream to S3 upload is not supported.

0.3.0

4 months ago

0.2.0

6 months ago

0.1.0

7 months ago