Android Question cannot upload file with ftp

freedom2000

Well-Known Member
Licensed User
Longtime User
Hi,

Following this example I wanted to upload a file to my Parrot Disco Wing.

Here is the very simple code I use :
B4X:
Private Sub btFTP_Click
    If Not(ftpChuck.IsInitialized) Then ftpChuck.Initialize("ftp", "192.168.42.1", 61, "", "") 'ftp port61 on the chuck to upload flightPlan
    ftpChuck.PassiveMode = True
    Dim myPath, myFile As String
    myPath = manager.GetString("missionFilesPath")
    If myPath = "" Then myPath = File.DirRootExternal
    myFile = "flightplan.mavlink"  
    Dim sf As Object = ftpChuck.UploadFile(myPath, myFile, True, "/")
    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
End Sub

As you can see it is more or less exactly the same code as in @Erel's example above.

The problem is that I get an error "cannot assign void value" on the dim sf as object line

error.jpg


Any idea where could be my error ?
Thanks
 

freedom2000

Well-Known Member
Licensed User
Longtime User
this is working.

But less "clean" !

B4X:
Private Sub btFTP_Click
    If Not(ftpChuck.IsInitialized) Then ftpChuck.Initialize("ftp", "192.168.42.1", 61, "", "") 'ftp port61 on the chuck to upload flightPlan
    ftpChuck.PassiveMode = True
    Dim myPath, myFile As String
    myPath = manager.GetString("missionFilesPath")
    If myPath = "" Then myPath = File.DirRootExternal
    myFile = "flightplan.mavlink"   
    ftpChuck.UploadFile(myPath, myFile, True, myFile)
End Sub


Sub ftp_UploadCompleted (ServerPath As String, Success As Boolean)
    Log(ServerPath & ", Success=" & Success)
    If Success = False Then
        Log(LastException.Message)
        ToastMessageShow("upload to chuck failed", False)
        Else
        ToastMessageShow("upload to chuck ok", False)
    End If
End Sub
 
Upvote 0
Top