0

I tried to directly upload the file stream as a parameter, but it didn't work.

var param = {
    Bucket: 'sql-dev',
    Key: 'Report',
    Body: new Buffer(fs.createWriteStream('./temp/ALL.csv'))
};  
s3bucket.putObject(param, function(err, data){
    if(err) console.log(err);
    else console.log(data);
});

How do I use that?

1
  • Define "didn't work." Commented Jun 23, 2016 at 10:52

1 Answer 1

1

You need to use a read stream, not a write stream. Also, you shouldn't be wrapping your stream inside a Buffer.

var param = {
    Bucket: 'sql-dev',
    Key: 'Report',
    Body: fs.createReadStream('./temp/ALL.csv')
};  
s3bucket.putObject(param, function(err, data){
    if(err) console.log(err);
    else console.log(data);
});
Sign up to request clarification or add additional context in comments.

2 Comments

You should be right, I just used 'readFile' that was working.
I have issue on uploading csv file. when i tried using .txt it works but when i tried .csv it returns me an error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.