Page 1 of 1

sync audio file

Posted: October 21st, 2020, 3:22 pm
by etuser
Hello,

Is it possible to sync audio file along with the data file using sync logic ? if yes, can i get an example

Many thanks

Re: sync audio file

Posted: October 21st, 2020, 6:16 pm
by aaronw
An audio file is like any other file and you'll use syncfile to synchronize it. The one caveat is they may be large.

To associate the audio file with the case, construct the file name from the id items.
string audio_file = maketext("%v-background-audio.m4a", HOUSEHOLD_ID);
background.save(audio_file);
From your menu application, loop through each file returned by dirlist and synchronize the file if it exists. As a final step you may want to delete the file after upload.
string dir_path = pathconcat(application, "../audio/");
list string audio_files;
dirlist(audio_files, dir_path);

do numeric i = 1 while i <= audio_files.length()

    // loop through each audio file in dir
   
if fileexist(audio_files(i)) then

        if syncfile
(PUT, audio_files(i), "/proj-name/audio/") then
            // delete after upload
           
filedelete(audio_files(i));
       
endif;

   
endif;

enddo;

Re: sync audio file

Posted: October 22nd, 2020, 12:57 am
by etuser
Many Thanks Aaron.