Class: S3Stream

S3Stream

new S3Stream(params, s3)

Writable stream interface for S3. Inherits stream.Writable
Parameters:
Name Type Description
params Object Same params object as AWS.S3.createMultipartUpload
Properties
Name Type Description
Bucket String The S3 bucket your file will go in.
Key String The full path to the object on S3, within its bucket.
s3 Object Authenticated instance of AWS.S3
Source:

Methods

<private> _write(chunk, encoding, callback)

Abstract stream.Writable method. Writes chunk to the stream.
Parameters:
Name Type Description
chunk Buffer The data to write to the stream.
encoding String Ignored because chunk is always a Buffer.
callback function Called when the chunk is successfully handled.
Source:

abort()

Abort the stream's multi-part upload. By default, this method will be called when any error is emitted from the queue so that the zombie parts are not left hanging around S3.
Source:

complete()

Finishes a multi-part upload. Any remaning data is flushed from the underlying queue. Once all parts have been uploaded to S3 and the 'flush' event is fired, completion starts. The stream emits a 'complete' event when the completed upload finishes with `err` and `response` arguments.
Source:

getUploadParams(extraParams) → {Object}

Helper to generate an object of params used by multiple S3 upload methods.
Parameters:
Name Type Description
extraParams Object Additional params to merge with the default params.
Source:
Returns:
Merged params.
Type
Object

init()

Initialize the instance with default values and listeners
Source:

initialized() → {Boolean}

Check whether the stream has been initialized with an S3 upload ID.
Source:
Returns:
True if the stream has an upload ID.
Type
Boolean

ready() → {Boolean}

Check whether the stream is ready to accept data.
Source:
Returns:
True if the stream is ready.
Type
Boolean

setThreshold(bytes)

Set the minimum size (in bytes) to upload in a non-final part.
Parameters:
Name Type Description
bytes Number Minimum upload size.
Source:

setupEvents()

Bind internal events. Helps methods act more independently and keeps most communication in events instead of nested calls.
Source:

setupQueue()

Setup an instance of S3Queue and binds the stream's upload() method to the queue's 'drain' event.
Source:

upload(body)

Upload a chunk of data to S3. Emits an 'uploaded' event on completion.
Parameters:
Name Type Description
body Buffer Chunk of data to upload.
Source: