5

Simple question: I want to upload/download large files around via REST. What is the best practice to do that? Are there any chunk-patterns, do I use multipart on the transport layer, what do you recommend?

Use case: we have an API where you can upload payments (e.g. 500mb) and download large account statement files. I am aware that other protocols exist to do that but how is it done with REST?

Marc Schlösser
  • 751
  • 2
  • 8
  • 17
  • 2
    You probably confuse REST with HTTP. REST is an architectural style if applied correctly decouples clients from services in a distributed system. It doesn't prescribe how a server should handle large(r) datasets. – Roman Vottner Dec 01 '17 at 13:47

1 Answers1

6

see the answers here. They might help with your problem:

REST design for file uploads

Large file upload though html form (more than 2 GB)

In conclusion: With REST you can simply use HTTP header fields to specify the content size, e.g use the Content-Type multipart/form-data in your request for files up to the server limit (usually 2GB - 4GB) and for files larger than that you will have to split the request in multiple parts.

Also check out this answer to see if byte-serving or chunked encoding makes sense in your application:

Content-Length header versus chunked encoding

MoGo
  • 76
  • 2