Android Tutorial Android FTP tutorial

Status
Not open for further replies.

sterlingy

Active Member
Licensed User
Longtime User
Problem Solved!!!!



As it turns out, I had to set FTP.Passive = True

Now everything works fine.

Also, and this may be a no-no, but I I to the FTP.Initialize out of the FirstTime if-then statement. The reason is that if I left the Camera activity, which is where all of this code resides, then went back to it, it wouldn't re-initialize the FTP.

Lastly, I put FTP.Close in the Pause subroutine. Since my camera Activity is locked into Landscape mode, the Activity will not pause if the phone orientation is rotated. Pausing will only take place when I leave the Activity with the back button.

Thanks for everyone's help.

Cheers,

Sterling
 

BarrySumpter

Active Member
Licensed User
Longtime User
FTP With IIS5.1 on WinXp Pro sp3 32bit

Make sure ftp is included with IIS5.1 install
Add or Remove Programs | Add/Windows Components | Internet Info Services (IIS) (ticked on) | Details ... | File Transfer Protocol (FTP) Service (ticked on)

Computer management | IIS | FTP Sites | Default FTP Site Properties | Security Accounts | Create New user like UID: ftpuser PW: zxcvb | Allow anonymous (ticked off) | allow IIS (ticked off)

Computer management | IIS | FTP SItes | FTP Site | IP Address: 192.168.1.6 (server IPAddress)

I DID NOT have to setup a new virtual directory.

Set router to port forward ftp port 21 to 192.168.1.6 (server IPAddress)

FTPExample app:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
            'FTP.Initialize( "FTP", "192.168.1.6", 21,  "ftpuser", "zxcvb")   'inTRAnet WORKS
            FTP.Initialize( "FTP", "myDomain.com", 21,  "ftpuser", "zxcvb")    'inTERnet WORKS
            'FTP.Initialize( "FTP", "ftp.myDomain.com", 21,  "ftpuser", "zxcvb") ' FTP.com DOES NOT WORK
                                                                                                    ' - don't know why in IIS5.1 
                                                                                                    ' - may need to contact my domain peeps
            
    End If
    Activity.LoadLayout("Main")
End Sub
 
Last edited:

rfresh

Well-Known Member
Licensed User
Longtime User
I meant that this could be an alternative for secured file transfers.

So what you're saying is that I can install an SSL Cert on my website and use regular B4A FTP and the files will go up or down encrypted via the SSL?

Update:

I moved my code over to one of my websites that has an SSL Cert on it.

My B4A FTP code is this:

B4X:
FTP2.Initialize("FTP", "ftp.my_ssl_website.com", 21, pUser, pPW)
FTP2.UseSSL = True
FTP2.PassiveMode = True

But when it tries to download a file I get this error in the log:

error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:683 0xad127577:0x00000000)

This site has no regular FTP server due to PCI requirements. It only has SFTP. So is this error msg because there is no regular FTP server installed?
 
Last edited:

gapi

Active Member
Licensed User
Longtime User
If I try to download more than twenty files returns me an error
B4X:
java.util.concurrent.RejectedExecutionException: pool=20/20 queue=0/0 Continue?
queue is full... solution ?

thanks
 
Last edited:

Rusty

Well-Known Member
Licensed User
Longtime User
Erel,
I am downloading a 32MB file using FTP. When my wireless/internet is "unoccupied" with other traffic, the full 32MB comes down just fine.
I notice when there is significant traffic on the wireless, it will download a portion of the file and "stall" out. Ultimately, it fails.
Is there a way to detect these errors and to recover from them?
Thanks,
 

Rusty

Well-Known Member
Licensed User
Longtime User
Yes,
B4X:
Sub MyFTP_DownloadCompleted (ServerPath As String, Success As Boolean)
   If Success Then
      Dim myzip As ABZipUnzip
      lblDownloaded.Text = "Unzipping..."
      myzip.ABUnzip(File.DirRootExternal & "/androidinstall.zip", File.DirRootExternal)
      File.Delete(File.DirRootExternal, "androidinstall.zip")
      pbProgress.Visible = False
      lblDownloaded.Text = "Installing..."
      btnInstall_Click
   Else
      Msgbox("Unable to download install information." & CRLF & LastException.Message, "Warning")
      Activity.Finish
   End If
End Sub

I get the error: org.apache.commons.net.io.copystramexception: ioExceptoin caught while copying
Any ideas?
Thanks,
 

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks Erel,
Is there a method to recover from this? Does this mean the problem is on the server side? Perhaps, does this mean the server is failing or too busy or what?
Most importantly, can I recover from this and do you have any ideas how to recover?
 

androh

Member
Licensed User
Longtime User
Closenow command does not work while upload process is running.
How can I terminate upload command?
 
Last edited:

AscySoft

Active Member
Licensed User
Longtime User
Closenow command does not work while upload process is running.
How can I terminate upload command?

As I understand from the first post of this thread, you can't because:
<<FTP.CloseNow will immediately close the connection, failing the remaining tasks.>>
So, because is on a separate thread, I just think that it's suppose to work exactly this way!
Why do you need to close the current upload/download file? It is too large?
 

androh

Member
Licensed User
Longtime User
Yes too large file. I'll try with service module...
 

AscySoft

Active Member
Licensed User
Longtime User
Yes too large file. I'll try with service module...

The service module is intended for background working, even if main application is closed. I don't see how this could help, the ftp library is processing in background...
Maybe you should ask Erel, to develop further this library for killing working thread...
I guess is not OK to upload partial files on ftp server... don't know...maybe I'm wrong.
 

androh

Member
Licensed User
Longtime User

I tried upload file with service module. After StopService(....) didn't kill ftp upload progress
:sign0085: Erel
 

androh

Member
Licensed User
Longtime User
What is exactly the problem? Does the download continue after you call CloseNow?
FTP.CloseNow should close the connection.

I'm uploading jpg file to ftp server. I want to cancel this upload process by user. But when I use ftp.close now, uploading is still running....
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…