diff --git a/examples/.gitignore b/examples/.gitignore index 0cffcb3..4a61e9e 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -1 +1,2 @@ -config.json \ No newline at end of file +config.json +video.mp4 diff --git a/examples/upload.js b/examples/upload.js index 3942a37..bc867df 100755 --- a/examples/upload.js +++ b/examples/upload.js @@ -11,11 +11,11 @@ AWS.config.loadFromPath('./config.json'); s3Stream.client(new AWS.S3()); // Create the streams -var read = fs.createReadStream('path/to/file'); +var read = fs.createReadStream('./video.mp4'); var compress = zlib.createGzip(); var upload = new s3Stream.upload({ - "Bucket": "bucket-name", - "Key": "key-name" + "Bucket": "storydesk", + "Key": "video.mp4.gz" }); // Handle errors. diff --git a/lib/s3-upload-stream.js b/lib/s3-upload-stream.js index 8645232..6efaa5d 100644 --- a/lib/s3-upload-stream.js +++ b/lib/s3-upload-stream.js @@ -122,8 +122,10 @@ module.exports = { receivedBuffers.push(remainder); receivedBuffersLength = remainder.length; - // Return the original buffer. - return combinedBuffer.slice(0, partSizeThreshold); + // Return the perfectly sized part. + var uploadBuffer = new Buffer(partSizeThreshold); + combinedBuffer.copy(uploadBuffer, 0, 0, partSizeThreshold); + return uploadBuffer; } else { // It just happened to be perfectly sized, so return it. diff --git a/package.json b/package.json index 4c063f4..21b2224 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "s3-upload-stream", "description": "Writeable stream for uploading content of unknown size to S3 via the multipart API.", - "version": "1.0.4", + "version": "1.0.5", "author": { "name": "Nathan Peck", "email": "nathan@storydesk.com"