File size of files saved in DirAssets

IamBot

Member
Licensed User
Longtime User
Hi, seems like when I use the following code below, the log tells me that the size of "legohead.png" is 0 bytes. I can assure, that this file is around 2,5kb.


Dim size As Long
size = File.Size(File.DirAssets, "legohead.png")

Log(size)


Any idea how to get the size of DirAssets files?
 

IamBot

Member
Licensed User
Longtime User
Yeah I noticed that.

I made it work by making a copy of the file first:

File.Copy(File.DirAssets,"legohead.png",File.DirInternal,"legohead.png")

size = File.Size(File.DirInternal, "legohead.png")
 
Upvote 0

IamBot

Member
Licensed User
Longtime User
Because of below reason :)


HttpClient1.Initialize("HttpClient1")

Dim req As HttpRequest
Dim size As Long

size = File.Size(File.DirAssets, "legohead.png")
InputStream1 = File.OpenInput(File.DirAssets, "legohead.png")


req.InitializePost("http://...php", InputStream1, size)
HttpClient1.Execute(req, 1)

Log(size)

Otherwise, it would upload a file worth of 0 bytes :p
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can also use HttpJob.PostFile. PostFile sends files smaller than 1mb as a bytes array. There is an advantage for sending files this way as HttpClient will automatically retry to send the file for up to 3 times if there was any error during upload. Since File.Size returns 0, the file will be treated as a small file (which I assume is correct).
 
Upvote 0
Top