Why is AWS S3 so slow? (Swift)

I use Amazon S3 to store profile images for user accounts in an iOS app using swift. I can get the photos that I want to get with S3, but uploading them takes a very long time. I do not know why this is happening. Is this how S3 works, or is there a better way to do something? This is my image upload code:

let downloadingFilePath1 = NSTemporaryDirectory().stringByAppendingPathComponent("temp-download") let downloadingFileURL1 = NSURL(fileURLWithPath: downloadingFilePath1) let transferManager = AWSS3TransferManager.defaultS3TransferManager() let readRequest1 : AWSS3TransferManagerDownloadRequest = AWSS3TransferManagerDownloadRequest() readRequest1.bucket = "groopapictures" readRequest1.key = self.searchTextField.text readRequest1.downloadingFileURL = downloadingFileURL1 transferManager.download(readRequest1).continueWithBlock { (task) -> AnyObject! in println(task.error) if task.error == nil { self.ppImageView.hidden = false println("Fetched image") self.ppImageView.image = UIImage(contentsOfFile: downloadingFilePath1) } return nil } 

Any help would be appreciated!

+4
source share
2 answers

Check in which queue you are working in your return block. If this is not the main queue, setting the image property of the UIImageView can take a long time to be "noticed" and updated. Check this by placing the image destination string inside dispatch_async() in the main thread.

If this does not help, start Charles and see how long it takes S3 to return the image.

+2
source

Download speed may vary depending on the region created by your bucket and your access point. Remember to select a region that is geographically close to your location, creating a bucket in AWS S3.

This image is taken from amazon s3 documentation

You can refer to the Amazon s3 documentation in the following link for an idea of ​​the bucket area.

Thanks!

0
source

All Articles