Page 1 of 1

FTP upload for Android

Posted: Mon Jan 09, 2017 4:22 am
by Lagi Pittas
I have a routine that works on windows to upload the sqlite file of my app to an ftp server.

the code that works perfectly on windows no problem. but I spent 2 days trying to fathom why it didn't work with the android tablet - RTFM (Read the Fine Manual). Turns out the libURLFTPfileupload I was using
doesnt work with Mobile , so ....

Took a few minutes to recode the routine using the URL syntax but it was copying 0 bytes under windows. Turns out I needed to close the database first and the result is a perfectly working program under windows.

But when I build an Android standalone the system does not get to the line (answer "2" ) after the put URL statement. No error is given , nothing.

I have selected the necessary libraries to be loaded and what to allow in the standalone settings. The file is only 26k in size. The path has to be correct because the first answer statement reads the correct data and the size in both environments.
This by the way is livecode 6.

Code: Select all

constant FTPUSER = "ftpacc@xxx.co.uk"
constant FTPPASS = "xxxx"
constant FTPHOST "blahblah"

global gDataPath

on mouseUp
      put URL ("binfile:" & lcFromPath) into lcFiledata
      answer "1" && the result && the length of lcFileData
      
      put lcFileData into url ("ftp://"& FTPUSER &":"& FTPPASS &"@"& FTPHOST & lcStamp &  "circuits.sqlite") 
      
      put the result into lcResult
      answer "2" && the result && the length of lcFileData

      if lcResult is not empty then
         answer "Update Failed:" && lcResult
      else
         answer "Upload Success"
      end if

end mouseUp

Re: FTP upload for Android

Posted: Tue Jan 10, 2017 8:18 pm
by AxWald
Hi,

I recently started making Android versions of some of my programs, and thought I had read somewhere that FTP upload is among the many common LC features still not yet implemented.

Anyways, I found the time to do a small test (for something I need anyways ...):

Code: Select all

   -- at first, I try a read/ update:
   --  (myFTPDir is a properly constructed ftp dir string
   --  including URLencoded User & Password)
   get URL (myFTPDir & "awa.txt")        --  this file already exists
   put it into myOld
   ask "File is:" & CR & myOld with "add some text"
   if it is empty then exit mouseUp
   put (myOld & CR & "# " & it) into URL (myFTPDir & "awa.txt")
   --  works flawlessly.
   --  Now I create a new file on the server:   
   put it into URL (myFTPDir & "bwa.txt")
   answer the result
   --  result is empty, the file is properly created
So, at least partially the functionality is there. I tested with my usual LC 6.7.10, on Android 4.2.2, compiled for 4.0.3 (API 15).
Interesting is that this triggers a "urlProgress" handler that I have in this stacks script ...

I'll try "full uploads" sometime later, when I'm done with LISTing directories & have fully understood the Android filesystem & its specialFolderCounterparts. Should you find something useful, I'd appreciate if you'd drop a line here - not this much information to find regarding LC & Android.

Have fun!