iOS Question FTP SendCommand Append problem

MikeGilligan

New Member
Licensed User
I've been working this problem for a week and cannot determine the cause of the file in the File.DirDocuments folder is not found.

Here is log:

Copying updated assets files (3)
Application_Start
[objEA_onInitialized]:eek:bjEA
[objEA_onClose]
Application_Active
file was uploaded successfully
Description: NSMapTable {
}
Requested file in DirDocuments: 20181211AM_001.plt
Contents of file: 32.9738028, -96.7208996, 0, 636, 43445.6524074, 2018-12-11, 15:39:27
Listing of files on FTP server:
20181210AM_001.plt
20181210PM_001.plt
20181211AM_001.plt
20181211PM_001.plt
APPE, Reply =Error: /var/mobile/Containers/Data/Application/C24DE70A-0251-4B5D-9F37-0C730F411B5F/Documents/20181211PM_001.plt: No such file or directory
Error: /var/mobile/Containers/Data/Application/C24DE70A-0251-4B5D-9F37-0C730F411B5F/Documents/20181211PM_001.plt: No such file or directory


And the pertinent code:

B4X:
Sub Process_Globals
    Private strPLTFileLines As String
    Private strPLTFileName As String
End Sub
Private Sub LocManager_LocationChanged (location1 As Location)
    strPLTFileName = strPLTFileName & "_001" & ".plt"
    Dim s As String
    File.WriteString(File.DirDocuments, strPLTFileName, strPLTFileLines)
    Dim mList As List
    mList = File.ListFiles(File.DirDocuments)
    s = mList.Get(6)
    Log("Requested file in DirDocuments: " & s)
    s = File.ReadString(File.DirDocuments, strPLTFileName)
    Log("Contents of file: " & s)
    Dim MyCommand As Object
'Get a file listing on the FTP server folder
    FTP.List("/")
    Wait For FTP_ListCompleted(ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
'FTP Send Append command
    s = File.DirDocuments & strPLTFileName
    FTP.SendCommand("APPE", s)
    Wait For (MyCommand) FTP_CommandCompleted (Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
    If Success Then
        hd.ToastMessageShow("Message Sent", True)
    Else
        hd.ToastMessageShow("Sending Message FAILED!", True)
    End If
    If Success Then
        Log("file was uploaded successfully")
    Else
        Log("Error uploading file")
    End If
End Sub
Sub FTP_CommandCompleted (Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
    Log(Command & ", Reply =" & ReplyString)
    If Success = False Then Log(LastException.Message)
End Sub
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
    Log("Listing of files on FTP server:")
    For i = 0 To Files.Length - 1
        Log(Files(i).Name)
    Next
    If Success = False Then Log(LastException.Message)
End Sub
 

MikeGilligan

New Member
Licensed User
You cannot call the 'append' command with FTP.SendCommand as append requires sending data on the data socket. FTP.SendCommand only sends the command on the command socket.

Ok, I can accept that and look for a work-around. I assume that the Upload command uses a different technique. It's still a mystery to my why the reply/error message states that the file to be appended cannot be found when it is obviously present.

Thank you for the quick reply and all your hard work.
 
Upvote 0
Top