0

I have an API to upload file to Microsoft Azure blob storage. Users can be uploading large files. Webclient handles files automatically, but its progress change event doesn't work. Here is a link to that issue though: UploadProgressChanged Event Not Being Called (More Details)

How do I use UnityWebRequest to upload large file without reading entire file into memory first?

  • I guess you can't. [UnityWebRequest.Put](https://docs.unity3d.com/Manual/UnityWebRequest-UploadingRawData.html) and [UnityWebRequest.Post](https://docs.unity3d.com/Manual/UnityWebRequest-SendingForm.html) need `byte[]` as inputs. – derHugo Mar 22 '19 at 15:25
  • That's the HLAPI, Uploading streamed data is supported by their LLAPI: [Creating Upload Handlers](https://docs.unity3d.com/Manual/UnityWebRequest-CreatingUploadHandlers.html) – Foggzie Mar 22 '19 at 15:33
  • @Foggzie as far as I can see in their example they also `// ... fill payload with data ...` (which is a `byte[]`) before they start the upload – derHugo Mar 22 '19 at 15:59
  • That's what the constructor accepts but it's still uploaded as a stream. _"This buffer is copied internally into native code memory and then used by the UnityWebRequest system when the remote server is ready to accept body data._". From the [UnityWebRequests page](https://docs.unity3d.com/Manual/UnityWebRequest.html) it states: "_It also supports high-demand features such as chunked HTTP requests, *streaming POST/PUT operations*, and...._" – Foggzie Mar 22 '19 at 16:10
  • @Foggzie But we still have to read entire file as byte first, and pass it as parameter right? – Harsh Priyadarshi Mar 23 '19 at 05:54
  • Yea, Unity's API requires the entire `byte[]` to be present and _afterwards_, handles streaming it through a Web Request. I'm not aware of a solution for streaming the contents of a file on disc into a network request that is streaming those chunks across the network at the same time without making multiple Web Request objects. – Foggzie Mar 24 '19 at 01:31

0 Answers0