objective c - Upload images using AWS S3 SDK v2 for iOS: Track progress -


I am uploading 15 photos in AWS S3 (v2) and I want to show the progress of each picture.

First, I created a AWSS3TransferManagerUploadRequest for a photo

  AWSS3TransferManagerUploadRequest * uploadRequest = [AWSS3TransferManagerUploadRequest new]. // Load uploadRequest Atts ... uploadRequest.uploadProgress = ^ (bytesSent int64_t, totalBytesSent, totalBytesExpectedToSend int64_t int64_t) {int progress = (int) (totalBytesSent * 100.0 / totalBytesExpectedToSend); DDLogInfo (@ "% d", progress); }  

Then I made more a NSArray

  BFTask * Work = [self.s3transferManager of BFTask: uploadRequest ]; [Functions addObject: work];  

Finally:

  [[BFTask taskForCompletionOfAllTasks: Work] continueWithExecutor: [BFExecutor mainThreadExecutor] withBlock: ^ ID (BFTask * task) {if (task.error! = Nil) {DDLogError (@ "Error: [% @]", task.error); } Else {DDLogInfo (@ "Done!"); } Return zero; }];  

I have the problem that the block associated with "upload progress" implements for the first 4 photos and then all are still uploaded but keep track of progress.

Any thoughts?

Thank you!

I'm not sure that this will help you but I'm using AdWords SDK v2 to AWS S3 I attach my code for how to show the uploading progress. In my case, I show the total progress of all the files. I think that you are not updating your progress on the main thread which may be an error in your code. Hope this helps

  (NSURL * myurl in self.myenum) {AWSS3TransferManagerUploadRequest * uploadRequest = [AWSS3TransferManagerUploadRequest new]. UploadRequest.bucket = @ "yourbucketname"; UploadRequest.body = myurl; Self.fileSize = @ ([[[NSFileManager defaultManager] attributesOfItemAtPath: myurl.path error: zero] [NSFileSize] unsignedLongLongValue]); Self.expectedToUpload = @ (self.expectedToUpload.unsignedLongLongValue + fileSize.unsignedLongLongValue); __Week type (self) weak Self = self; UploadRequest.contentLength = self.fileSize; UploadRequest.uploadProgress = ^ (int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {dispatch_sync (dispatch_get_main_queue (), ^ {@synchronized (weakSelf) {// Anselog (@ "% @ = & gt;% llu% llu", myurl, TotalBytesSent, TotalBytesExpectedToSend); // NSLog (@ "Progress =>% f", (weakSelf.fileAlreadyUpload.unsignedLongLongValue * 1.0 / weakSelf.expectedToUpload.unsignedLongLongValue) * 100); weakSelf.fileAlreadyUpload = @ (weakSelf.fileAlreadyUpload.unsignedLongLongValue + Baitsset); WeakSelf.myprogressbarController.progressbarView.progress = [NSN number number of Sathunssaining long (weak Swynfailale Phleaplod Krenksessaindlong freakish value / Kmjorslf.aksifiktuupi Odksoin the Gelong freakish value) * 100];} itself. Maigreshnbarkantrolrkprogrambardrishy. Progress = [Ansanmber Nanbrvisfot my progress] [Self. MyprogressbarControllerkprogressbarView need to set requirements: Yes]});  

I upload files using the upload control:

  - (minus) more controllers {__vek Taipf (self) weak Self = self; NSMutableArray * functions = [NSMutableArray new]; AWSS3 Transfer Manager * Transfer Manager = [AWSS 3 TransferManager Default S3 Transfer Manager]; In the (self.arrayOfUploadRequests objectAtIndex AWSS3TransferManagerUploadRequest * uploadRequestLocal) {[functions addObject: [[transferManager more: uploadRequestLocal] continueWithBlock: ^ id (BFTask * work) {if (! Task.error = null) {if (task.error. code! = AWSS3TransferManagerErrorCancelled & amp; & amp; task.error.code = AWSS3TransferManagerErrorPaused) {NSLog (@ !: "error% @" StatusLabelFailed); WeakSelf.uploadFailure = @ ([weakSelf.uploadFailure intValue] + 1); }} And {weak} Self.uploadCount = @ ([weakSelf.uploadCount intValue] + 1); WeakSelf.uploadSuccess = @ ([weakSelf.uploadSuccess intValue] + 1); } Return zero; }]; }  

Comments