nathanpeck / s3-upload-stream

A Node.js module for streaming data to Amazon S3 via the multipart upload API
MIT License
347 stars 46 forks source link

Parallel uploads revisted #29

Closed meandavejustice closed 9 years ago

meandavejustice commented 9 years ago

I'm having an issue with parallel uploads, much like issue #17.

I've tried creating a new instance of the s3Upload object each time, but I keep getting this error:

TypeError: Cannot call method 'createMultipartUpload' of undefined
    at createMultipartUpload (/home/meandave/Code/davejustice.com/node_modules/s3-upload-stream/lib/s3-upload-stream.js:341:18)
    at uploadHandler (/home/meandave/Code/davejustice.com/node_modules/s3-upload-stream/lib/s3-upload-stream.js:162:9)
    at uploadRemainingData (/home/meandave/Code/davejustice.com/node_modules/s3-upload-stream/lib/s3-upload-stream.js:276:11)
    at afterDoneWithOriginalEnd (/home/meandave/Code/davejustice.com/node_modules/s3-upload-stream/lib/s3-upload-stream.js:288:7)
    at process._tickDomainCallback (node.js:463:13)
var AWS = require('aws-sdk');
AWS.config.loadFromPath('./config.json');
AWS.config.httpOptions = {timeout: 5000};
var s3Stream = require('s3-upload-stream')(new AWS.S3());

var bucketConfig = {
  "Bucket": "davejusticedotcom",
  "ACL": "public-read",
  "ContentType": "audio/mpeg"
};

module.exports = function (part, cb) {
  bucketConfig.Key = part.filename;
  if (!~part.headers['content-type'].indexOf('wav')) {
    bucketConfig.ContentType = part.headers['content-type'] ;
  }

  var upload = new s3Stream.upload(bucketConfig);// .concurrentParts(5);
  // upload listeners redacted.
  part.pipe(upload);
};
meandavejustice commented 9 years ago

Digging a bit deeper it looks like caching of the client has been added. When going back to just using s3Upload without creating a new instance.

I am still getting this error from issue 17

error s3 upload::: Failed to upload a part to S3: {"message":"The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.","code":"NoSuchUpload","time":"2014-12-04T07:41:34.023Z","statusCode":404,"retryable":false,"retryDelay":30}
 Additionally failed to abort the multipart upload on S3: NoSuchUpload: The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.
uploaded::: { Location: 'https://davejusticedotcom.s3-us-west-2.amazonaws.com/2014-12-04T07%3A41%3A32.249Z.gif',
nathanpeck commented 9 years ago

You actually need to remove the new in front of s3Stream.upload

I have adjusted this in the docs on Github, but I think there is still a bad doc on NPM itself.

On Thu, Dec 4, 2014 at 2:44 AM, Dave Justice notifications@github.com wrote:

Digging a bit deeper it looks like caching of the client has been added. When going back to just using s3Upload without creating a new instance.

I am still getting this error from issue 17

error s3 upload::: Failed to upload a part to S3: {"message":"The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.","code":"NoSuchUpload","time":"2014-12-04T07:41:34.023Z","statusCode":404,"retryable":false,"retryDelay":30} Additionally failed to abort the multipart upload on S3: NoSuchUpload: The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed. uploaded::: { Location: 'https://davejusticedotcom.s3-us-west-2.amazonaws.com/2014-12-04T07%3A41%3A32.249Z.gif',

— Reply to this email directly or view it on GitHub https://github.com/nathanpeck/s3-upload-stream/issues/29#issuecomment-65548375 .

meandavejustice commented 9 years ago

Removing the new gives me the same error that was posted in issue #17. The cached client doesn't appear to be working correctly.

error s3 upload::: Failed to upload a part to S3: {"message":"The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.","code":"NoSuchUpload","time":"2014-12-04T07:41:34.023Z","statusCode":404,"retryable":false,"retryDelay":30}
 Additionally failed to abort the multipart upload on S3: NoSuchUpload: The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.
uploaded::: { Location: 'https://davejusticedotcom.s3-us-west-2.amazonaws.com/2014-12-04T07%3A41%3A32.249Z.gif',
nathanpeck commented 9 years ago

Which version of the client are you using?

meandavejustice commented 9 years ago

1.0.6

meandavejustice commented 9 years ago

I was someone still updating a reference in the bucketConfig when my next part was passed into the method. it was totally my fault, carry on!