Hi,
I've managed to get my app to connect to me NAS via Non-Secure FTP with no probs and upload / list files folder in the folder, however when I change it to FTPS it seems to connect ok (NAS Log show is connects successfully) however the List_Completed function always returns Success=False and the UploadFile Function uploads the file but returns Success=False.
When I Log the last exceptions it returns:
- Folder is not writable or an error occurred: java.lang.RuntimeException: Error uploading file.
- 200 PORT command successful
Any help would be much appreciated.
Sub TestFTP(url As String, username As String, pwd As String, LocalPath As String)
FTP.Initialize("FTP", url, 21, username, pwd)
FTP.UseSSL = True
FTP.UseSSLExplicit = True
FTP.PassiveMode = False
Dim CustomSSL As CustomTrustManager
CustomSSL.InitializeAcceptAll
FTP.SetCustomSSLTrustManager(CustomSSL)
FTP.List(LocalPath)
End Sub
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Directories() As FTPEntry, Files() As FTPEntry)
Dim msg As String
If Success Then
If Directories.Length > 0 Or Files.Length > 0 Then
Log("Folder is available at " & ServerPath)
Else
Log("Folder is empty.")
End If
Dim testContent As String
testContent = "This is a test file."
File.WriteString(File.DirInternal, "/test.txt", testContent)
' Upload file
FTP.TimeoutMs = 120000
Dim sf As Object = FTP.UploadFile(File.DirInternal, "/test.txt",False, txtLocalPath.text & "test.txt")
Wait For(sf) FTP_UploadCompleted(ServerPath As String, Success As Boolean)
If Success Then
' Delete the test file
FTP.DeleteFile(txtLocalPath.text & "test.txt")
msg = "The Upload path specified is Available and ready for Upload!"
MsgboxAsync(msg,"Local Path Settings Valid")
Log("Folder is writable.")
Else
msg = "Folder is not writable or an error occurred!"
MsgboxAsync(msg,"Local Path Settings Invalid")
Log("Folder is not writable or an error occurred: " & LastException.Message )
End If
Else
msg = "Could not confirm if the folder is Available. Check upload location secutity settings and Try Again."
If ServerPath = txtLocalIP.Text Then
MsgboxAsync(msg,"Local Path NOT Available")
Else
MsgboxAsync(msg,"Remote Path NOT Available")
End If
Log("Error checking folder availability: ")
End If
' Disconnect from the FTP server
If FTP.IsInitialized Then
FTP.Close
End If
End Sub
I've managed to get my app to connect to me NAS via Non-Secure FTP with no probs and upload / list files folder in the folder, however when I change it to FTPS it seems to connect ok (NAS Log show is connects successfully) however the List_Completed function always returns Success=False and the UploadFile Function uploads the file but returns Success=False.
When I Log the last exceptions it returns:
- Folder is not writable or an error occurred: java.lang.RuntimeException: Error uploading file.
- 200 PORT command successful
Any help would be much appreciated.
Sub TestFTP(url As String, username As String, pwd As String, LocalPath As String)
FTP.Initialize("FTP", url, 21, username, pwd)
FTP.UseSSL = True
FTP.UseSSLExplicit = True
FTP.PassiveMode = False
Dim CustomSSL As CustomTrustManager
CustomSSL.InitializeAcceptAll
FTP.SetCustomSSLTrustManager(CustomSSL)
FTP.List(LocalPath)
End Sub
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Directories() As FTPEntry, Files() As FTPEntry)
Dim msg As String
If Success Then
If Directories.Length > 0 Or Files.Length > 0 Then
Log("Folder is available at " & ServerPath)
Else
Log("Folder is empty.")
End If
Dim testContent As String
testContent = "This is a test file."
File.WriteString(File.DirInternal, "/test.txt", testContent)
' Upload file
FTP.TimeoutMs = 120000
Dim sf As Object = FTP.UploadFile(File.DirInternal, "/test.txt",False, txtLocalPath.text & "test.txt")
Wait For(sf) FTP_UploadCompleted(ServerPath As String, Success As Boolean)
If Success Then
' Delete the test file
FTP.DeleteFile(txtLocalPath.text & "test.txt")
msg = "The Upload path specified is Available and ready for Upload!"
MsgboxAsync(msg,"Local Path Settings Valid")
Log("Folder is writable.")
Else
msg = "Folder is not writable or an error occurred!"
MsgboxAsync(msg,"Local Path Settings Invalid")
Log("Folder is not writable or an error occurred: " & LastException.Message )
End If
Else
msg = "Could not confirm if the folder is Available. Check upload location secutity settings and Try Again."
If ServerPath = txtLocalIP.Text Then
MsgboxAsync(msg,"Local Path NOT Available")
Else
MsgboxAsync(msg,"Remote Path NOT Available")
End If
Log("Error checking folder availability: ")
End If
' Disconnect from the FTP server
If FTP.IsInitialized Then
FTP.Close
End If
End Sub