Android Tutorial Android FTP tutorial

Status
Not open for further replies.

LucaMs

Expert
Licensed User
Longtime User
1 min to check the event name: it is [YouEventName]_DownloadCompleted, where YouEventName is the name you set when you initialized FTP.

You should verify the ftp server path.

Note that this your code:
B4X:
For i = 0To Files.Length - 1
Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
FTP.DownloadFile("Namen/", True, PfadDownload,name)
Next

saves only one file, if you don't change the value of the variable [name] inside the For loop (name & i, for
 
Last edited:

arnold steger

Member
Licensed User
Longtime User
i have tested the upload file by file, total 7files
whit explore i have open the files directly from ftp server path for check data in files, work fine
i whant download all files from my server path (folder:Namen/)
on my device path maked 7 empty files whit the correct name from server

message #240
 

arnold steger

Member
Licensed User
Longtime User
Full path to the filename are my problem.
This code work fine, thanks.

B4X:
Sub ButtonDownloadList_Click
    Dim FolderName As String    :FolderName="Namen/"

    FTP.List(FolderName)

End Sub

Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
    Dim FolderName As String    :FolderName="Namen/"

    Log(ServerPath)
    If Success = False Then
        Log(LastException)
    Else
    TimerDownload.Initialize("TimerDownload",3000)
    TimerDownload.Enabled=True

        For i = 0 To Folders.Length - 1
            Log(Folders(i).Name)
        Next     
        For i = 0 To Files.Length - 1
            Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
            FTP.DownloadFile(FolderName&Files(i).Name,True, PfadDownload,Files(i).Name)
            ToastMessageShow(Files(i).Name&" wird geladen...",False)
        Next
    End If
 
    If Success AND Files.Length>0 Then
    TimerDownload.Enabled=False
    ToastMessageShow(Files.Length&" Dateien wurden erfolgreich geladen",True)
    Else
    TimerDownload.Enabled=False
    ToastMessageShow(ServerPath&" Dateien konnten nicht geladen werden",True)
    End If
 
End Sub

Sub TimerDownload_tick
    ToastMessageShow("wird geladen..." ,False)
   
End Sub
 
Last edited:

Cüneyt Gargin

Member
Licensed User
Longtime User
Yes. Go to the Libraries tab and check FTP.
If you have just added the FTP files and don't see FTP in the list of libraries, then right click and choose Refresh.
Where can I find FTP files.. and where and how will I copy...
 

arnold steger

Member
Licensed User
Longtime User
When use my code #257 then show afer 1 second "33 Dateien wurden erfolgreich geladen".
When checked in device folder after 30 second is all of list in my device.
How can check when all of files from my list is downloaded?
 

Julian Rogers

New Member
Licensed User
Longtime User
If a file already exists in your local folder, (ie, downloading "test.txt" onto a directory that already has a "test.txt"), what will happen? Will it delete the old file and replace with the new one? Will it rename anything?
 

arnold steger

Member
Licensed User
Longtime User
i have insert this code. not work.
how can tested if download of list is compled?

B4X:
If Success Then
ServerGeladen=ServerGeladen+1
End if   
If Success AND ServerGeladen>=Files.Length Then
    ToastMessageShow(Files.Length&" Dateien wurden erfolgreich geladen",True)
    TimerDownload.Enabled=False
End if
 

JAVIERGARCIA

Member
Licensed User
Longtime User
Hi Erel,
please look:
attempt to rename a file in a ftp upload, so:

FTP.UploadFile(File.DirRootExternal, "1.jpg", True, "/public_html/FOTOS-NGI/ '" & IDNUM & "' & ".jpg" ")

which it is a variable IDNUM
but I missed his syntax, it does not know why

and if you only put him
FTP.UploadFile(File.DirRootExternal, "1.jpg", True, "/public_html/FOTOS-NGI/ '" & IDNUM & "'")
FTP is correct, but when trying to access the file, tells me "invalid image"
I do not understand where failure

another thing,

Sub FTP_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
Dim s As String
s = "Uploaded " & Round(TotalUploaded / 3000) & "KB"
If Total > 0 Then s = s & " out of " & Round(Total / 3000) & "KB"
Log(s)
End Sub

3000 is the most you might go up via ftp?

thanks
best regard
 

JAVIERGARCIA

Member
Licensed User
Longtime User
Hello,
if I make a ftp upload image when trying to open it once downloaded, always she tells me that the image is not valid,
why?


thanks
 

Kwame Twum

Active Member
Licensed User
Longtime User
Hello,
if I make a ftp upload image when trying to open it once downloaded, always she tells me that the image is not valid,
why?

1. Does the DownloadComplete Sub get raised?
2. Can you post the code you used in downloading the image? - It's possible you're downloading a file with no extension (from the look of the Post#257)
 

juventino883

Member
Licensed User
Longtime User
Hi!, I have a doubt, is possible to create a new folder in the FTP server through this library?, and how can i do it?, thanks!!!
 

juventino883

Member
Licensed User
Longtime User
Ok ok, i see, so if i want to create a specific folder in the server, the best option is to create a java server with b4j to implement it?, or what other solution could be factible?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…