amazon web services - AWS Javascript Uploading Multiple Files with progress reported -


scenerio....

i'm trying upload number of files aws through javascript api. while number of files may many (100 - 500), managing first sending file information web server (via ajax) parse name, size, etc... , insert information database. return id of newly created record web page , send file s3 using 'id' file name. way, believe creating unique records , file names.

problem...

since ajax routine in loop, file upload s3. cannot script give me valuable feedback on upload progress (the upload works fine).

any of following make me happy...

  1. a div total upload size (all files) , total progress reported.
  2. a list of files being uploaded totals , amounts loaded.
  3. a div reports "20 out of 520 files loaded"

my code...

var aj = $.ajax({             url: 'handler.php',             type: 'post',             data: { packnameid: packnameid,                     number: number,                     name: name                 },             success: function(result) {                      // initialize amazon cognito credentials provider                 aws.config.region = 'us-east-1'; // region                 aws.config.credentials = new aws.cognitoidentitycredentials({                 identitypoolid: '********************',                 });                  var bucket = new aws.s3({params: {bucket: 'traseindex'}});                 var params = {key: result+".pdf", contenttype: file.type, body: file};                  bucket.upload(params).on('httpuploadprogress', function(evt) {                 document.getelementbyid('total').innerhtml = evt.total;                 document.getelementbyid('status').innerhtml = +" of " + files.length + " " + parseint((evt.loaded * 100) / evt.total)+'%'                 console.log("uploaded :: " + parseint((evt.loaded * 100) / evt.total)+'%');                  }).send(function(err, data) {                   document.getelementbyid('total').innerhtml = +" of "+ files.length + " complete";                 });             }         }); 

no matter how update httpuploadprogress piece, fail achieve goal. instane, "i of file.length" reports files done, yet parseint evaluation continues show me percentage complete of each file upload processes.

ive tried creating multiple divs id of loop iteration "i", append each of them parseint evaluation, percentage shows in last div created.

if point me in correct direction, how approach this, appreceiate it.

thanks.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -