0

I am bit new to HTTP/2. I have learned that using HTTP/2 we can send multiple requests to the server without waiting for previous responses. Well I want to send an image file to the server which is large (more then 500 MB). There are following ways as listed here

  1. Base64 encode the file, at the expense of increasing the data size by around 33%.
  2. Send the file first in a multipart/form-data POST, and return an ID to the client. The client then sends the metadata with the ID, and the server re-associates the file and the metadata.
  3. Send the metadata first, and return an ID to the client. The client then sends the file with the ID, and the server re-associates the file and the metadata.

I donont want to use first solution because it will increase the file size by 33%. I want to use 3rd solution.

As I am using HTTP/2 so my questions are

  1. Can I send metadata and image simultaneously without waiting for ID from the server ?
  2. If yes, then how can I implement ? Like do I have to do multithreading at server end for a client or how can I associate metadata and image with each other ?
  3. If no then should I go for conventional style of HTTP/1.1 ?

I am using Restful and JSON for communication. More specifically I am using C# command-line client to send image and Asp.Net as server.

Junaid
  • 2,572
  • 6
  • 41
  • 77

1 Answers1

0

You can use multipart/related type to make a request with related mime-types. i.e in your case you can send an image along with a JSON body data.

You can refer Google drive file upload api which has a very similar implementation.

Community
  • 1
  • 1
Deva Gerald
  • 284
  • 2
  • 6