B4J Question I upload via FTP and this problem appears if the remote target folder or name is in Arabic, even though the server supports the Arabic language.

AlfaizDev

Well-Known Member
Licensed User
Longtime User
I upload via FTP and this problem appears if the remote target folder or name is in Arabic, even though the server supports the Arabic language.

B4X:
    Dim sf As Object = sftp.UploadFile(DeviceFolder, DeviceFile, False, ServerFilePath)
    Wait For (sf) ftp_UploadCompleted (ServerPath As String, Success As Boolean)
    If Success Then
        
        Log("file was uploaded successfully")
    Else
        Log("Error uploading file")
    End If


B4X:
uploads/دروس
D:\1.jpg
java.lang.RuntimeException: Error uploading file.
550 uploads/????/1.jpg: No such file or directory
    at anywheresoftware.b4a.net.FTPWrapper$2.run(FTPWrapper.java:241)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1589)
Error uploading file
 
Solution
the server's support for utf8 could be the issue, but the problem may be on the client side.
depending on which version of apache's ftp class our network library uses, it may be possible
to switch from ascii (the default) to utf8. i think we recently had a similar case with a member trying
to upload non-ascii filenames.

update: our version of net.jar does support setControlEncoding("UTF-8"). so, probably, with javaobject.

update II: this compiles, runs and appears to work. i don't have any ftp server to test with...
B4X:
    ftp.Initialize("ftp","host",21,"user","pass")
    
    Dim r As Reflector
    r.Target = ftp
    Dim client As JavaObject
    client = r.GetField("client")...

teddybear

Well-Known Member
Licensed User
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
the server's support for utf8 could be the issue, but the problem may be on the client side.
depending on which version of apache's ftp class our network library uses, it may be possible
to switch from ascii (the default) to utf8. i think we recently had a similar case with a member trying
to upload non-ascii filenames.

update: our version of net.jar does support setControlEncoding("UTF-8"). so, probably, with javaobject.

update II: this compiles, runs and appears to work. i don't have any ftp server to test with...
B4X:
    ftp.Initialize("ftp","host",21,"user","pass")
    
    Dim r As Reflector
    r.Target = ftp
    Dim client As JavaObject
    client = r.GetField("client")
    client.RunMethod("setControlEncoding",Array("UTF-8"))
    Log("char set now: " & client.RunMethod("getControlEncoding",Null))
    ' ...
 
Last edited:
Upvote 0
Solution

AlfaizDev

Well-Known Member
Licensed User
Longtime User
the server's support for utf8 could be the issue, but the problem may be on the client side.
depending on which version of apache's ftp class our network library uses, it may be possible
to switch from ascii (the default) to utf8. i think we recently had a similar case with a member trying
to upload non-ascii filenames.

update: our version of net.jar does support setControlEncoding("UTF-8"). so, probably, with javaobject.

update II: this compiles, runs and appears to work. i don't have any ftp server to test with...
B4X:
    ftp.Initialize("ftp","host",21,"user","pass")
   
    Dim r As Reflector
    r.Target = ftp
    Dim client As JavaObject
    client = r.GetField("client")
    client.RunMethod("setControlEncoding",Array("UTF-8"))
    Log("char set now: " & client.RunMethod("getControlEncoding",Null))
    ' ...
Thank you very much
It works efficiently
 
Upvote 0
Top