erdomke/Innovator.Client

Chunk file upload not working

Opened this issue · 0 comments

When I try to upload file more than 16Mb to Innovator I get the exception (timeout, but it happens earlier than 100 sec as default timeout).
After some investigations I discovered that exception occurs at the second file chunk sent. Server returns http error 400. I think this is due to the lack of "Transfer-Encoding: chunked" in the http request header.
Ok. I made the chunkSize local variable of CommandFile.AsContent as public static member of CommandFile class and added

if (file.Length > CommandFile.chunkSize) req.SetHeader("Transfer-Encoding", "chunked");

to TransactionalUploadCommand.UploadFile.

But now I get the System.ObjectDisposedException at CommandFile.FileStreamContent.SerializeToStream.
Apparently for some reason the FileStreamContent object is disposed before its chunk is sent. I don't understand why this can happen.

Now as workaround I increased the chunkSize value to 500Mb and can upload large files.