B4J Question Copy remaining part of inputStream to a file

Discussion in 'B4J Questions' started by wl, May 30, 2019.

  1. wl

    wl Well-Known Member Licensed 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
     
  2. Erel

    Erel Administrator Staff Member Licensed 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.
     
    wl likes this.
  3. wl

    wl Well-Known Member Licensed User

    Would that mean that the file needs to be taken fully in memory ? By using streams I would be able to avoid this, no ?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Use a custom type with B4XSerializator. It is very simple.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice