Marc Schlösser
Marc Schlösser

Reputation: 781

Up-/Download of big files via REST

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?

Upvotes: 6

Views: 18509

Answers (1)

MoGo
MoGo

Reputation: 86

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

Upvotes: 7

Related Questions