iosruby-on-railsswiftfirebasephotos

what is the best (or most optimal) practice for uploading images to online storage with iOS?


I'm currently making an iOS app that requires image uploading functionality. I'm using Firebase for image storage and I'm using a ruby on rails API that I built for everything else (e.g. authentication, user accounts, etc.) image uploading works at this point in the app, however, it's a little slow (this is alarming because I'm the only one using it. It's not like there is a bunch of HTTP requests being sent to the API or firebase at one time, it's just me testing it). This is how I'm currently handling uploads:

  1. The user chooses a photo to upload.
  2. The photo gets converted to a png string representation and gets sent to firebase storage
  3. The download URL of the photo from firebase gets returned
  4. That URL is then sent to API and assigned to profile_image attribute of that particular user.

And that is done. So, when the user want's to see that photo:

  1. a get request is made to the API which responds with all sharable attributes of a user like usernames and what not, but also the URL to that image.
  2. then the app 'downloads' that image and puts it inside of a UIImageView.

Some cocoa pods I'm using to achieve this:

  1. Alamofire
  2. SwiftyJSON
  3. FirebaseStorage
  4. SDWebImage

My question is whether or not this is a good way to approach image uploads in my circumstances. It is a little slow, but I don't know if that is because I'm using Heroku's free web hosting service for my API, or if it is because the way in which I'm uploading images and retrieving them is just overly complicated and can be simplified.


Solution

  • If you are taking images out of a camera which are hi res (11 mega pixels) and your only use is to display said image on a phone / iPad (ie not print them out onto a billboard), then resize the image before you send it to Firebase and use a much smaller image, it will increase performance significantly.

    You delay is likely due to your filesize.

    If you need large files sizes, implement caching !