Photo and file offline sync #898
-
@adrianhall as spoken about on #897 I would like your advice on how you would approach this. You mentioned it would be relativly easier. Could you explain some more. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It's a simple queue mechanism - create a queue on device. When you add a file to the offline area, also add an entry in the queue. When you are synchronizing data, you upload the file and update the queue to indicate it has been uploaded. Generally, I have a table that has the files in it. Each file has a filename, a state { Local, Error, Uploaded } and an error message in case it was Error. When I go to synchronize, I look for all "Local" files, then upload each one in turn. If the upload is successful, I change the state to Uploaded; if the upload was not successful, I change the state to Error and specify the error. Once that is complete, I push changes in the table to the remote server (use Datasync Framework). This then allows other clients to see if there is a file coming (i.e. state == Local or Error) or if I can expect the file to be where I need it to be. I generally upload to Azure Blob Storage, so I have an API that generates a SAS token for my upload and sends that back to me, then use the Azure Storage SDK to actually upload the file with that SAS token. SAS token has a lifetime attached to it, so I need to get a new one if I update. |
Beta Was this translation helpful? Give feedback.
-
@adrianhall thank you very much for the detailed response, and you are correct that does seem like a simple solution. I think I was over complicating it in my head. |
Beta Was this translation helpful? Give feedback.
It's a simple queue mechanism - create a queue on device. When you add a file to the offline area, also add an entry in the queue. When you are synchronizing data, you upload the file and update the queue to indicate it has been uploaded.
Generally, I have a table that has the files in it. Each file has a filename, a state { Local, Error, Uploaded } and an error message in case it was Error. When I go to synchronize, I look for all "Local" files, then upload each one in turn. If the upload is successful, I change the state to Uploaded; if the upload was not successful, I change the state to Error and specify the error.
Once that is complete, I push changes in the table to the remote serve…