Synchronize pictures from device to server

Discussions about syncing data via Bluetooth, Dropbox, FTP, and using CSWeb
Post Reply
CMH
Posts: 31
Joined: April 1st, 2022, 1:54 am

Synchronize pictures from device to server

Post by CMH »

Hi,

I am using a logic to take picture during data collection. Same logic is applied with 10 items/questions in CAPI application. Pictures are being captured successfully and stored with a unique ID at a specific location of device i.e., “Internal shared storage\Android\data\gov.census.cspro.csentry\files\csentry\FEM\photos”.

1. Can someone help me in writing logic to upload all pictures by one enumerators at once in one day.
2. However the pictures he/she has sent already, should not be repeated while synchronization at second time or next day. 3. Also if such logic is available, where to add it?
justinlakier
Posts: 152
Joined: November 21st, 2022, 4:41 pm

Re: Synchronize pictures from device to server

Post by justinlakier »

Hi,

I recommend checking out the example from the SyncFile documentation here https://www.csprousers.org/help/CSPro/s ... ction.html. You can modify it so that it sends all images from the enumerator's Photos folder to be synced. Additionally, you can modify it by asking "If SyncFile(etc)" instead of just "SyncFile(etc)". If the photos are not successfully synced, you can give an error message, but if the photos are successfully synced, you can move the local copies from the Photos folder to a Sent folder so that they won't be repeated the next time you sync the Photos folder. You can put this logic wherever makes sense for your app, but I recommend that you add this Sync code in the logic for a menu control field so that the enumerator can choose when to sync the photos, log out, or perform other menu control actions.

Hope that helps,
Justin
CMH
Posts: 31
Joined: April 1st, 2022, 1:54 am

Re: Synchronize pictures from device to server

Post by CMH »

Thank you very much. Photos are synced from device to dropbox sever successfully using following logic.

if syncconnect(dropbox) then
syncfile(PUT, "/storage/emulated/0/android/data/gov.census.cspro.csentry/files/csentry/FEM/photos/*.jpg", "/Photos/Alam/");
syncdisconnect();
endif;

Howerver two further solutions are required.

1. I also want that those pictures sent to server should move simoultaniously from photos folder in device to sent folder in the same device so they would not repeat next time enumerator sync the photos folder. Currently enumerators are doing by themselve.
2. Using the same CAPI application, the pictures from all enumerators should be saved in folder at dropbox/server by their name. Currently, i am using one CAPI application for one enumerator by his/her name (like above logic is only for anumerator named "Alam"). One solution can be calling field/item for name of enumerator through logic and then while syncing picture upload to dropbox and creat folder with name of that enumerator. But not aware how to write/adjust logic for this.
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Synchronize pictures from device to server

Post by Gregory Martin »

When is your survey going into the field? In CSPro 8.0, we are introducing binary dictionary items, where you could store your images, and then syncdata will take care of the intelligence of not sending images multiple times to the server.

We are putting out a beta this week, with the final release probably in October, so if that works with your timeline, that would be the easiest approach.
CMH
Posts: 31
Joined: April 1st, 2022, 1:54 am

Re: Synchronize pictures from device to server

Post by CMH »

Thanks. Its great news. Looking forward for the version 8. Current survey is expected to start coming week from Monday.
Post Reply