B4J Question HTTP PostOutputStream ?

Discussion in 'B4J Questions' started by wl, Jun 10, 2019.

  1. wl

    wl Well-Known Member Licensed User

    Hi,

    I want to upload a (potentially) large set of bytes from a client (B4J and B4I) to a B4J http server.

    So far I found that a PostBytes method, but it seems this requires a byte array. So I guess the entire set of bytes should be in memory before uploading.
    If I would use a PostFile I would first need to store the bytes in a local file.

    Isn't there something like a PostOutputStream, so that I can use a stream to write the bytes to be uploaded to ?

    I would need such a thing both for uploading from an iOS device as well as a B4J client.

    Thanks
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    What is the expected size of this data?

    Where does it come from?
     
  3. wl

    wl Well-Known Member Licensed User

    The intention is to write an iOS app to upload movies and pictures from the iPhone to the server. When a user would upload a large 4K video ...

    But note that I would need to add a header (first X bytes) to it: so the stream would be

    headerbytes+bytes of the movie

    Currently I create a new file with this contents (so that the movie temporarily takes twice the space on the device) so this second file can be uploaded...

    Ideally I am not taking the file in memory (RAM usage) nor create a second file (storage usage), but send the stream...
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You will need to save it to a file. In B4A and B4J you can create a stream and write to it however you will still need to set the content length. It will be much simpler to write the data to a temporary file and delete it when done.
     
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