Skip to content

Commit

Permalink
Fix AWS asset receiver upload connection end.
Browse files Browse the repository at this point in the history
The asset upload endpoint would not properly fire an end event when
working with the AWS S3 plugin. The cause of this was that we were
piping the file data through to the S3 uploader but our return string
had no way to detect that the S3 API's done callback had finished. Here
we fix the issue by closing the stream when S3 reports that the file has
successfully uploaded.
  • Loading branch information
Laurence Liss authored and lliss committed Mar 19, 2016
1 parent 3a71905 commit 05bffb8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/plugins/fileStorage/AwsS3Storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ class AwsS3Storage {
* Create a writeable stream to which we can write file data.
*
* @param {string} assetName - The name of the asset that needs to be written.
* @param {function} done - Callback.
* @return {object} - The writeable stream to store the data.
*/

createWriteStream(assetName, done) {
var writeStream = through2();
var request = this.s3.upload({Key: assetName, Body: writeStream});
var self = this;
request.send(function(error, data) {
// We must alert the write stream that we have finished or it will
// not close the connection to the client.
writeStream.emit('close');
if (error) {
self.logger.error(error);
}
Expand Down

0 comments on commit 05bffb8

Please sign in to comment.