Page 1 of 1

FTP on Android

Posted: Sun Nov 18, 2012 4:35 am
by joel.epsteinBUS31vi
Hi all -

The following code is working fine on iOS, but not the Android simulator. I'd be grateful for any advice for how to make it work.

Peace

Joel

Code: Select all

   put "http://www.projectiveart.com/PAapp/count/count.txt" into countURL
   put URL countURL into tTempCount
   put tTempCount into tNumberOfFiles
   put tNumberOfFiles+1 into tNumberOfFiles
      
   constant FTPHOST = "www.projectiveart.com"
   constant FTPUSER = "{my user name}"
   constant FTPPASS = "{my password}"   
   put tNumberOfFiles into URL "binFile:/count.txt"
   put tNumberOfFiles into url ("ftp://" & FTPUSER & ":" & FTPPASS & "@" & FTPHOST&"/PAapp/count/count.txt")

Re: FTP on Android

Posted: Fri Nov 23, 2012 3:22 pm
by Mark
hi Joel,

Which part doesn't work?

Kind regards,

Mark

Re: FTP on Android

Posted: Fri Nov 23, 2012 4:26 pm
by FourthWorld
joel.epsteinBUS31vi wrote:

Code: Select all

   put "http://www.projectiveart.com/PAapp/count/count.txt" into countURL
   put URL countURL into tTempCount
   put tTempCount into tNumberOfFiles
   put tNumberOfFiles+1 into tNumberOfFiles
      
   constant FTPHOST = "www.projectiveart.com"
   constant FTPUSER = "{my user name}"
   constant FTPPASS = "{my password}"   
   put tNumberOfFiles into URL "binFile:/count.txt"
   put tNumberOfFiles into url ("ftp://" & FTPUSER & ":" & FTPPASS & "@" & FTPHOST&"/PAapp/count/count.txt")
If you check "the result" after the last statement, I'd guess that you'll find an error noting the URL is invalid.

The URL being used contains a service specifier of "http", but then you prepend that with a service specifier of "ftp", giving you:

Code: Select all

ftp://user:password@http://www.projectiveart.com/PAapp/count/count.txt"
If you remove the service specifier from the URL, you'd have:

Code: Select all

ftp://user:password@www.projectiveart.com/PAapp/count/count.txt"
...which is probably what you'll need.

Note that some servers are set up to use "www.*" only for HTTP access, so you may need:

Code: Select all

ftp://user:password@projectiveart.com/PAapp/count/count.txt"
Check the value of "the result" after that call for guidance; a good practice anyway, since all sorts of errors can occur during any client-server transaction, and checking "the result" will give you the opportunity to handle those gracefully.

Re: FTP on Android

Posted: Fri Nov 23, 2012 6:10 pm
by Mark
Hi,

If I run this script, I get

ftp://{my user name}:{my password}@www.projectiveart.com/PAapp/count/count.txt

which doesn't include "http". Some servers need ftp instead of www and sometimes the correct form is ftp.projectiveart.com/www/PAapp/count/count.txt

Mark