Dim stream As OutputStream
Dim size_i As Int
stream.InitializeToBytesArray(20)
PostInputStream.Initialize(stream)
Log("PostStreamCount:" & PostInputStream.Count)
Dim EOL As String
EOL = Chr(13) & Chr(10) 'CRLF constant matches Android end of line character which is chr(10).
Dim b() As Byte
b = ("--" & boundary & EOL & "Content-Disposition: form-data; name=" _
& QUOTE & "file" & QUOTE & "; filename=" & QUOTE & FileName & QUOTE _
& EOL & "Content-Type: " & "application/octet-stream" & EOL & _
"Content-Transfer-Encoding: binary" & EOL & EOL).GetBytes("UTF8")
'stream.WriteBytes(b, 0, b.Length)
size_i = b.Length
PostInputStream.WriteBytes(b,0,b.Length)
Log("PostStreamCount:" & PostInputStream.Count)
Dim in As InputStream
in = File.OpenInput(Dir, FileName)
UploadLength = in.BytesAvailable
'PostInputStream.Initialize(in)
'File.Copy2(in, stream) 'read the file and write it to the stream
File.Copy2(in, PostInputStream)
Log("PostStreamCount:" & PostInputStream.Count)
b = EOL.GetBytes("UTF8")
'stream.WriteBytes(b, 0, b.Length)
PostInputStream.WriteBytes(b, 0, b.Length)
size_i = size_i + b.Length
b = (EOL & "--" & boundary & "--" & EOL).GetBytes("UTF8")
'stream.WriteBytes(b, 0, b.Length)
PostInputStream.WriteBytes(b, 0, b.Length)
size_i = size_i + b.Length
'b = stream.ToBytesArray
'b= PostInputStream.ToBytesArray
UploadLength = UploadLength + size_i
tmrProgress.Enabled = True
Dim req As HttpRequest
req.InitializePost2(link, b)
'req.InitializePost(link, PostInputStream,UploadLength)
req.SetContentType("multipart/form-data; boundary=" & boundary)
req.SetContentEncoding("UTF8")
req.SetHeader("Authorization", authHeader)
Return req