amazon web services - Creating S3 Files in a Loop - Node.JS + AWS-SDK -


i'm trying create set of files binary data received api call files never created, promise.then function called:

for(var in filesections){     var content = filesections[i].split((/content-length: [0-9]*/));     var filename = content[0].split('filename=')[1].trim();     var file = {bucket : 'mybucket', key: root+'/'+folder+'/'+subfolder+'/'+filename, body: content[1]};     console.log('creating file: '+file.key ); ***code runs @ least here each file***     promises.push(s3.upload(file)); } ***.then function fires*** promise.all(promises).then(confirmproposal()).catch(function(err){context.done(err);}); 

earlier on in process create file in s3 using code:

var application = {bucket : 'mybucket', key: root+'/'+folder+'/'+subfolder+'/application.xml', body: filesections[0]}; s3.upload(application,function(err,data)     {         ...files created in here on successful response ...     }); 

which works , file created. know i'm doing wrong?

change line:

promises.push(s3.upload(file)); 

to this:

promises.push(s3.upload(file).promise()); 

the aws nodejs sdk functions don't return promise directly. example s3.upload() function returns aws.s3.managedupload object. have call .promise() on returned object promise.


Comments

Popular posts from this blog

4x4 Matrix in Python -

python - String indices must be integers and while issue -

python - PyInstaller UAC not working in onefile mode -