1

I have successfully implemented Sync Logic to sync my local data (text related data) with web server (was referrign this link) and that is working.

but I have to sync images too. here is the way I want to do that,

user will create a product (title, 5 images (1 compulsory, 4 optional), description).

Now, I can follow the same scenario like one I did above but getting confusion in image uploading, as it would be not feasible I can upload it all the same time or what if data saved on server and internet goes off hence images not uploaded, there might change other user won't see the images.

Can anyone have the best approcah? please guide me.

Thanks,

Community
  • 1
  • 1
Parth Pandya
  • 1,460
  • 3
  • 18
  • 34

1 Answers1

1

The challenge here is that you are dealing with a long transfer time, due to a large chunk of data, am I right? If that's the case, then I would recommend the protocol below. I would also use the same protocol for the small data syncs as well, since there is also a risk that the sync is interrupted.

  1. Set a flag on the local device that a sync is in progress.
  2. Upload to a temporary location on the server.
  3. Once the upload is complete, call a web service on the server, to notify the server that the transfer has completed. A web service is preferable, since that will allow you to receive a response once the web service is completed. The web service moves the files to their final destination.
  4. When you receive the response, you can update the flag set in step 1, and you will know that the files are where they should be on the server.
Sheamus
  • 6,506
  • 3
  • 35
  • 61
  • The challenge is which approach to use to upload the images on the server as I can't wait untill all the images get uploaded on the server. – Parth Pandya Sep 14 '15 at 12:54
  • Why can't you wait? Are you saying that you want the app to perform another operation? – Sheamus Sep 14 '15 at 13:13
  • Please elaborate. I'm not sure what you're trying to do. – Sheamus Sep 14 '15 at 13:55
  • my app will work on offline mode too, So I am allowing user to just create product locally and start other thing, the product will upload in background. – Parth Pandya Sep 14 '15 at 13:57
  • So you're trying to figure out how to set up the background task so it won't time out? – Sheamus Sep 14 '15 at 14:15
  • yes, and How to manage it locally, I mean How should I maintain the association with images and product. – Parth Pandya Sep 14 '15 at 14:38
  • Normally, you could use iCloud with Core Data, but you've already gotten your own sync to work with the data, so now it is a matter of using a Database on the server, such as MySQL, and Core Data on the device. – Sheamus Sep 14 '15 at 14:46
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/89600/discussion-between-parth-pandya-and-sheamus). – Parth Pandya Sep 14 '15 at 14:50