B4J Question Copy remaining part of inputStream to a file

wl

Well-Known Member
Licensed User
Longtime User
Hi,

If I have an inputstream (eg: in a webhandler) and I first read a number of bytes from it through "ReadBytes" and then do a File.Copy2 to copy the stream, will it copy from the current position on ?

I would like to be able to upload a JSON string and a file at the same time back and forth between a B4J webserver and a B4I client and I would like to avoid using zips (which I could use it seems) because I then would need to copy files and so on ..

Thank
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
will it copy from the current position on ?
Yes.

I would like to be able to upload a JSON string and a file at the same time back and forth between a B4J webserver and a B4I client and I would like to avoid using zips (which I could use it seems) because I then would need to copy files and so on ..
Would be simpler to create a custom type with an array of bytes and any other information you like, serialize it with B4XSerializator and send it.

The custom type should be declared in the main module of both projects.
 
  • Like
Reactions: wl
Upvote 0

wl

Well-Known Member
Licensed User
Longtime User
Yes.


Would be simpler to create a custom type with an array of bytes and any other information you like, serialize it with B4XSerializator and send it.

The custom type should be declared in the main module of both projects.

Would that mean that the file needs to be taken fully in memory ? By using streams I would be able to avoid this, no ?
 
Upvote 0
Top