iOS Question FTP don't transfer any file

akinnovation

Member
Licensed User
Longtime User
I have this PList add to my B4i app:
Plist:
#Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: true
    #MinVersion: 9
    'per GPS
    #PlistExtra:<key>NSLocationWhenInUseUsageDescription</key><string>Used to display the current navigation data.</string>
    #PlistExtra:<key>NSLocationUsageDescription</key><string>Used to display the current navigation data.</string>
    'per ftp
    '#PlistExtra: <key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><true/>
    #PlistExtra: <key>NSExceptionDomains</key><dict>
    'list the excluded domains (example.com and b4x.com)
    #PlistExtra: <key>akinnovation.it</key><dict><key>NSIncludesSubdomains</key><true/><key>NSAllowsArbitraryLoads</key><true/>
    'end of excluded domains
    #PlistExtra: </dict>
    #PlistExtra: </dict>
#End Region

Sub Process_Globals
    Public App As Application
    Public NavControl As NavigationController
  
    'Dim DbName="presenze.s3db" As String                    '''''''228 prova margherita   ''''212 civitella '''''233 SANTA RITA '''186 pietra d'angolo ''264 JBI (fiumicino) 101(giovanivdarno)
    Dim DbMName="movimenti8.s3db" As String
    Dim FTP As FTP
    Dim statoFTP As String

End Sub
and this is the code of the initialization of the ftp and the upload function.
FTP initialization and upload:
Private Sub Button1_Click
    If Not(DbM.IsInitialized) Then
        DbM.Initialize(dbpath,Main.dbmname,False)
    End If
    Dim qry As String="insert into movimenti (idterm,UID,dataora,causale,modoctr,note)"    &" values("""&"1234567890"&""","""&"idute=7456"&""","""&"oggi"&""","""&"L"&""","""&"attivo"&""","""&"NO"&""")"
  
    Dim SenderFilter As Object = B4XPages.MainPage.DbM.ExecQueryAsync("SQL",qry,Null)
    Wait For (SenderFilter) SQL_QueryComplete (Success As Boolean, rs As ResultSet)
    If Success Then
        DbM.close
    End If

End Sub
#Region gestione FTP 'esegue aggiornamento tablet prima scarica , poi carica dati ed infine tenta di aggiornare app
Sub FTP_Start
    DoFTPInitialize
    If Main.statoFTP="UP" Then
'        Main.FtpStatus.down=False
'        Main.FtpStatus.up=False
'        Main.FtpStatus.apk=False
    End If
  
End Sub
Sub DoFTPInitialize
    Main.FTP.Initialize("FTP","ftp.xxxx.xx",21,"xxx","@@@@@@")
    Main.FTP.PassiveMode=True
'    If trasferito Then
'        installaApk("otto.apk")
'        Return
'    End If
  
    If Main.statoFTP="UP" Then
        'Log("Sending File...")
        'logdb("trasferisco dati")
        Dim data,yy,hh As String
        DateTime.DateFormat="yyyyMMdd"
        DateTime.TimeFormat="HHmmss"
        hh=DateTime.Time(DateTime.Now)
        yy=DateTime.Date(DateTime.Now)
        data=yy&hh
      
        nomefiletx="1234567890_"&data&".s3db"
        Dim up As Object=Main.FTP.UploadFile(dbpath, nomefiletx,False, nomefiletx)
        Wait For (up) FTP_UploadCompleted (ServerPath As String, Success As Boolean)
        If Success Then
            FTP_UploadCompleted(ServerPath, Success)
        Else
            nomefiletx="no" 'messaggi.Visible=False
        End If
  
    End If
End Sub




Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
    If Main.statoFTP="UP" Then
        File.delete(dbpath,nomefiletx)
        DbM.Initialize(dbpath,Main.DbMName,False)
        If Success Then
            nomefiletx=""
            DbM.ExecNonQuery("delete from movimenti")
        End If
    End If
End Sub

#End Region


Private Sub Button2_Click
    Main.statoFTP="UP"
    FTP_Start
This is the same configuration that I use on my android app and with android it work fine
In the B4i app the result of upload si always FALSE.
I'm observed also the Filezilla server where I send the file. With B4i I don't see any request, not even the first access request( user, password,...), nothing!

The IOS version is 15.3.1

I attach a project that reply the trouble. Because I'm desperate don't succeded in understand my error.(This is, also, my first B4i app)
 

Attachments

  • Project.zip
    13.7 KB · Views: 200
Last edited:

akinnovation

Member
Licensed User
Longtime User
ATS Disabled
and Log
LOG error:
    false, <B4IExceptionWrapper: Error Domain=caught_exception Code=0 "Error opening stream (/private/var/mobile/Containers/Data/Application/77041FBC-36FE-4E5C-A38D-16BE6078A314/tmp/1234567890_20220306195158.s3db): Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory" UserInfo={_kCFStreamErrorCodeKey=2, _kCFStreamErrorDomainKey=1}" UserInfo={NSLocalizedDescription=Error opening stream (/private/var/mobile/Containers/Data/Application/77041FBC-36FE-4E5C-A38D-16BE6078A314/tmp/1234567890_20220306195158.s3db): Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory" UserInfo={_kCFStreamErrorCodeKey=2, _kCFStreamErrorDomainKey=1}}>

SOLVED. I use a wrong name in uploadfile...o_O?
many thanks Erel and excuse me for my banal error
 
Upvote 0
Top