Android Question problems multiple sending files to the server

Roberto P.

Well-Known Member
Licensed User
Longtime User
I'm trying to send multiple files (pdf) from the device to the server, but is sent only last on the list !

Will you help me figure out where I'm wrong?

Client Code:

B4X:
Dim aListFile As List    =    File.ListFiles( aPath )
    Dim aFileName As String
    Dim aFileSize As Int
   
    If aListFile.IsInitialized Then
       
        For i = 0 To aListFile.Size -1
            aFileName    =    aListFile.Get(i)
           
            Dim aExist As Boolean    =    File.Exists(aPath, aFileName)

           
            If aExist Then
           
                aFileSize = File.Size(aPath, aFileName)
                Log("File Name : " & aFileName & " Size: " & aFileSize)
           
                Dim out As OutputStream
                out.InitializeToBytesArray(aFileSize)
                Dim In As InputStream = File.OpenInput(aPath, aFileName)
                File.Copy2(In, out)
                out.Close
                In.Close
               
                Dim su As StringUtils
                j.PostBytes(aLink & "?type=ticket&filename=" &  su.EncodeUrl(aFileName, "UTF8"), out.ToBytesArray)
               
           
            End If
           
        Next
       
    End If


Thank you
 

Attachments

  • files.png
    files.png
    6.7 KB · Views: 132

Roberto P.

Well-Known Member
Licensed User
Longtime User
What function is better to send pdf files of about 900kb?

B4X:
j.PostBytes(aLink & "?type=ticket&filename=" &  aFileName, out.ToBytesArray)

or 
               
j.PostFile(aLink & "?type=ticket&filename=" & aFileName, aPath, aFileName)

thanks
 
Upvote 0
Top