B4X:
Sub SaveFile(URL As String, Dir As String , Filename As String)
Dim FS As OutputStream ,Iss As InputStream, Buffer(1024) As Byte , BytesRead As Int ,Start As Int ,Cache As Int
FS= File.OpenOutput(Dir, Filename , False )
Iss = HttpUtils.GetInputStream(URL)
Start=0
Do Until Bytesread = -1
BytesRead = iss.ReadBytes( Buffer, 0 , Buffer.Length )
If bytesread>-1 Then Cache = bytesread
FS.WriteBytes(Buffer, 0, Cache)
start=start+ BytesRead
Loop
iss.Close
fs.Close
End Sub
I keep getting an error on "BytesRead = iss.ReadBytes( Buffer, start , Buffer.Length )", it says start is out of bounds after the first read (so start=1024 at this point) I'd try 0, but that doesnt make sense, it should keep resaving the first 1024 bytes.
I don't want to use GetBitmap, then resave it as a jpg (cause that'd add more compression artifacts to the thumbnail) or a bmp (larger filesize)
Last edited: