Upload photos IOS Swift

Asked

Viewed 151 times

1

I have an application where I need to upload some photos to a server, when I upload a single photo works all right, now if it is two or more photos takes expressive time to complete the operation. I spend these photos turning them into Base64. Does anyone have any idea how I can make these uploads faster.

  • 1

    Ta using Swift or objc? I recommend using Alamofire: https://github.com/Alamofire/Alamofire Look at the Uploading part, it will definitely help you.

1 answer

0


You don’t need (and nor should), convert Base64 images to send images to a remote server.

Should not, because Base64 is not a compression algorithm, it does the opposite, it increases (and quite) the payload weight, maybe that’s why its upload takes so long. Transferring in Base64 when both ends can interpret the same binary format in common is bad practice.

And don’t need because, any server with any application service running that fits, can read the field of binary Boundary to convert it into binary image format (gif, jpg, png, wherever) on the server itself.

If you will upload many images in high quality, ai is already a ANOTHER history. You’ll have to create your own upload strategy so it doesn’t cost you too much networking and interface time until the upload completes. In that case, I would save everything locally and upload in the background slowly using a background task or a secondary operation with the app open.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.