B4A Library New Net library - Android FTP, SMTP and POP3

Status
Not open for further replies.

xky

Member
Licensed User
Longtime User
I use it and it work fine.
But if I upload a file, if the file name is a UTF8 charactor, it will have 553 error.
For example: 1.txt is uploaded OK; 你好.txt will be have 553 (could not create file) back.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I was able to upload a file with that name to an FTP server. Though it seems like its name was later lost. The control channel uses ISO-8859-1 encoding.

You can change it with this code:
B4X:
Dim r As Reflector
r.SetStaticField("org.apache.commons.net.ftp.FTP", "DEFAULT_CONTROL_ENCODING", "UTF-8", "java.lang.String")
It didn't make any difference with the server I've tested.

Interesting reading about this issue: https://wiki.filezilla-project.org/Character_Encoding
 

xky

Member
Licensed User
Longtime User

I use a Linksys EA6700 Router, it has FTP, I tested each encode, but it still have the 553 problem. I added the Reflector as you given the code to me, it's not work.
But I can drag a file name like 你好.txt to the FTP server with windows file manager. So I think there's something I can do but I don't know.
B4X:
Sub Button3_Click
    CardList=File.ListFiles(File.DirDefaultExternal)
    If CardList.Size=0 Then Return
    Dim r As Reflector
    r.SetStaticField("org.apache.commons.net.ftp.FTP", "DEFAULT_CONTROL_ENCODING", "UTF-8", "java.lang.String")
    FTP.Initialize("FTP", "server.lingker.com", 21, "ShowMe", "00000000")
    Dim i As Byte
    Dim s As String
    For i = 0 To CardList.Size-1
        s=CardList.Get(i)
        FTP.UploadFile(File.DirDefaultExternal, s, True, "/ShowMe/" & s)
    Next
    FTP.Close
End Sub
This is my code, you can use the infomation in code to connect my FTP for Test.
I use CuteFTP to upload 测试这个文件.txt is OK. So I think B4A can do it too.
FTP express pro is an android app, it can upload to my server with 测试这个文件.txt too. Why this lib can't?
 
Last edited:

xky

Member
Licensed User
Longtime User
It seems it do nothing, still not UTF-8.
 

xky

Member
Licensed User
Longtime User
Yeah,I'm very happy to tell you. It's worked. I can upload any name of file now.(such as 测试这个文件.txt)
So I think it is different.
B4X:
r.SetField("_controlEncoding", "UTF8", "java.lang.String")
change current encoding to UTF-8 but
B4X:
r.SetStaticField("org.apache.commons.net.ftp.FTP", "DEFAULT_CONTROL_ENCODING", "UTF-8", "java.lang.String")
not.
I suggest add FTP.SetControlEncoding to the lib, for non-ASCII users.

Thankyou very much for the helping.
 

MMORETTI964

Member
Licensed User
Longtime User
I've a problem downloading (or uploading) a large file with FTP libraries.
Should be something related to a firewall who closes the command connection.

There are something I can use for keeping alive the connection (a keepalive socket option or a "NOOP" command - not-recommended but sometime useful - while transferring a file)?

Thank you.

Maurizio
 

MarcoRome

Expert
Licensed User
Longtime User
Do you see THIS
 

MMORETTI964

Member
Licensed User
Longtime User
I can't send a command on the same connection while a command is executing...
I'm trying to change the KeepAlive on that server.
I think if I could set KeepAlive on the command control (or send a NOOP on that command) I could bypass every firewall problem I would encounter on my way...

Maurizio
 

MarcoRome

Expert
Licensed User
Longtime User
Hi @Erel.
Can i set a time-out in the current library type:
ftpClient.setControlKeepAliveTimeout(xxx)
or to use this command to 'keep-alive' ??
Thank you
Marco
 

JackKirk

Well-Known Member
Licensed User
Longtime User

aviario

Active Member
Licensed User
Longtime User
Hi. first of all, sorry for my english.
We have a program in B4A 6.5 versión using this library to connect to Fillezilla FTP Server.
Now we change to B4A 7.3 versión and the software not run. When we try to connect, the program not do it.
There an update of library?

tha
 

Steini1980

Active Member
Licensed User
Longtime User
Hi@all,
after upgrading the NET-Library to newest Version 1.77 i got the following exception if I try to start my App:

B4X:
Installing file.
PackageAdded: package:b4a.dms.blabla
java.lang.ClassNotFoundException: anywheresoftware$b4a$net$FTPWrapper
    at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:544)
    at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:516)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:320)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at b4a.dms.blabla.main.afterFirstLayout(main.java:91)
    at b4a.dms.blabla.main.access$100(main.java:16)
    at b4a.dms.blabla.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6873)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Could you please help me?! does I have to delete anything before?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…