Synchronizing photos along with data

Discussions about syncing data via Bluetooth, Dropbox, FTP, and using CSWeb
Forum rules
New release: CSPro 8.0
Post Reply
asheffel
Posts: 23
Joined: July 14th, 2014, 9:07 am

Synchronizing photos along with data

Post by asheffel »

Hi,

I am setting up an application to run on Android devices and synchronize with Dropbox using the new features in CSPro 7.1. I have set up the Deploy Application to send the application and associated look-up files to the tablet and have the synchronization of the data file to Dropbox working. However, we are also collecting a photo of the health facility and I would like to synchronize the photos to Dropbox as well. Do you know if this is possible. Currently, the photos are being stored in the same folder as the data file on the tablet.

Many thanks for any ideas you may have!

Ashley
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Synchronizing photos along with data

Post by aaronw »

You can use syncfile to transmit a file from the device to Dropbox. Here's a snippet of logic syncing an external data file and an image file.
    if syncconnect(dropbox) then

        if not syncdata(BOTH, SIMPLECAPI_DICT) then
            errmsg("Data upload failed.");
        endif;

        if not syncfile(PUT, "resources/icon.png", "/icon.png") then
            errmsg("File upload failed.");
        endif;

    else
        errmsg("Connection failed. You may need to give CSEntry permission to access Dropbox.");
    endif;
In your case you'll need to name the photo so they are unique.
asheffel
Posts: 23
Joined: July 14th, 2014, 9:07 am

Re: Synchronizing photos along with data

Post by asheffel »

Thanks for the quick response! The photos all have a unique name labeled with the unique facility ID so that shouldn't be a problem.

One additional question-- where should I put this logic to sync the photos? We are working in South Sudan so the internet is a bit limited and data collectors will probably only be able to sync once a week. As such, I don't want to put it in the data entry application itself. Should I build a separate data entry application or batch application that only contains the sync logic? Or other suggestions?

Many thanks!
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Synchronizing photos along with data

Post by aaronw »

It makes sense to have two separate applications. One to collect data and another to let the interviewer decide when to transmit data. In addition, I would go ahead and synchronize the dictionary in the new application. That way all data is transmitted in one shot.
asheffel
Posts: 23
Joined: July 14th, 2014, 9:07 am

Re: Synchronizing photos along with data

Post by asheffel »

Thanks for the help! I'm getting closer but now having a problem with the pathway to where the photos are stored.

I created an application called photo_sync to synchronize the photos which are stored in csentry/SARA_v2.3/Data. I'd like it to sync all .jpg files located in this folder. However, I' m having a hard time getting writing the correct path name to where the pictures are located. I've tried a bunch of different path names and have not found anything that works. Any suggestions for correctly specifying the path name would be much appreciated!

Here is the code I am using currently:


if $ = 1 then
if syncconnect(dropbox) then

if not syncfile(PUT, "csentry/SARAv2.3/Data/*.jpg", "/Photos") then
errmsg("Photo upload failed.");
endif;

else
errmsg("Connection failed. You may need to give CSEntry permission to access Dropbox.");

syncdisconnect();

endif;
endif;

if $ = 2 then
stop()
endif;
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Synchronizing photos along with data

Post by josh »

Use syncfile(PUT, pathname(csentry) + "SARAv2.3/Data/*.jpg", "/Photos")
asheffel
Posts: 23
Joined: July 14th, 2014, 9:07 am

Re: Synchronizing photos along with data

Post by asheffel »

Awesome! Got it working now. Many thanks!!
Post Reply