1

The object that comes off of ReadAsByteArrayAsync().Result creates a different file than the one that was uploaded.

Here's the code:

    public static HttpResponseMessage UploadVideo(HttpRequestMessage Request) {    
        byte[] data = Request.Content.ReadAsByteArrayAsync().Result;
        BinaryWriter writer = new BinaryWriter(File.Open(@"D:/dev/test_file.mp4"));
        BinaryWriter writer = new BinaryWriter(File.Open(name, FileMode.OpenOrCreate));
            writer.Write(data);
            writer.Flush();
            writer.Close();
        return new HttpResponseMessage(HttpStatusCode.Accepted);
    }

This a text view of the original video file. enter image description here

This is the file uploaded from ReadAsByteArrayAsync().Result enter image description here

It seems like all the raw data is there except that it came with some extra strings. Can anyone explain why this is happening and how to get the original file?

Thanks

Fenix
  • 31
  • 7

1 Answers1

1

the problem here is that you try to compare incoming request and original file. At this moment your upload request is a multipart form. check this: https://stackoverflow.com/a/15680783/5902888

Igor Gnedysh
  • 144
  • 1
  • 10