Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large files not uploaded (size > highWatermark) #15

Open
msageryd opened this issue Oct 28, 2015 · 4 comments
Open

Large files not uploaded (size > highWatermark) #15

msageryd opened this issue Oct 28, 2015 · 4 comments

Comments

@msageryd
Copy link

I can't get large file uploads to work other than if I raise highWatermark to above the file size. I thought highWatermark was the limit for when a new chunk should be sent. Have I misunderstood something?

const AWS = require('aws-sdk');
AWS.config.update({
  accessKeyId: accessKey, 
  secretAccessKey: secretKey
});

const S3 = AWS.S3;
const S3S = require('s3-streams');
const read = fs.createReadStream('./big.pdf') //18MB file

const s3Upload = S3S.WriteStream(new S3(), {Bucket: 'myBucket', Key: 'test'});

read.pipe(s3Upload)
.on('finish', function() {
  console.log(`finished piping to S3.. `);
})
@msageryd msageryd changed the title Large files not uploaded (file > highWatermark) Large files not uploaded (size > highWatermark) Oct 28, 2015
@trevtrich
Copy link

I'm having this issue as well. Any movement on this?

@msageryd
Copy link
Author

I suspect that the author won't prioritize this since the official AWS SDK handles this quite easily nowadays. You can throw anything on it (stream or buffer) and it just works =) I'm using the SDK instead of S3-streams and I'm a happy camper.

@msageryd
Copy link
Author

msageryd commented May 17, 2016

My apology to Izaak for possibly leading richardson-trevor away from S3-Streams. But since my issue has been open for several months I suspect that the module might have been abandoned.

Here is how I do it (returns a promise):

//Declare AWS "global" to the module for use in all AWS related functions
const AWS = require('aws-sdk');
AWS.config.update({
  region: 'yourRegion',
  accessKeyId: 'yourAccessKey',
  secretAccessKey: 'yourSecret'
});

function upload(options) {
  const s3 = new AWS.S3();
  const s3Params = {
    Bucket: options.bucket,
    Key: options.key,
    Body: options.file  //stream or buffer
  };

  const s3Options = {
    partSize: 5 * 1024 * 1024,
    queueSize: 1
  };

  return new Promise(function uploadPromise(resolve, reject) {
    s3.upload(s3Params, s3Options, function s3Upload(err) {
      if(err) return reject(err);
      resolve();
    });
  });
}

@trevtrich
Copy link

Thanks for the input, that's probably right on. We'll take a second look at that with what we're doing!

Sent from my iPhone

On May 17, 2016, at 11:35 AM, michaelswe [email protected] wrote:

I suspect that the author won't prioritize this since the official AWS SDK handles this quite easily nowadays. You can throw anything on it (stream or buffer) and it just works =) I'm using the SDK instead of S3-streams and I'm a happy camper.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants