i have following snippet of code copies buffer local file when successful, copies s3.
however, don't know how deal callback s3 storage function ".send(callback)" requires. i'd integrate in promise chain also.
var writefile = promise.promisify(fs.writefile) var filename = input + "jpg" writefile(archive + "/" + filename, buffer) .then(function(){ console.log("yay, file written"); outputs.push(filename); }) .then(function(){ var body1 = fs.createreadstream(archive + "/" + filename) var s3obj1 = new aws.s3({params: {bucket: 'mybucket', key: filename}}); s3obj1.upload({body: body1}) .on('httpuploadprogress', function(evt) { console.log(evt); }) .send(function(err, data) { console.log(err, data) }); })
my intuition lead me expect way of having bluebird's api generate me nodejs-style callback allows me move on promises.
i don't seem able promisify send function.
thanks
Comments
Post a Comment