Anthony
Anthony

Reputation: 399

RESTful Web Service Upload/Download Large Data With JSON

What is the best practice if you are implementing web services that will send and receive large files to/from clients. Normally we are sending JSON objects, but it could be problematic if we include large data payload inside of the JSON objects. We need to provide JSON data as well as a payload, anyone have experience with something similar?

Upvotes: 0

Views: 6979

Answers (2)

Vladislav Bauer
Vladislav Bauer

Reputation: 962

Base64 is a very inefficient way of doing this, but universal. You could send your files using HTTP Post-request with special parameter "multipart/form-data".

Upvotes: 0

Steven Huwig
Steven Huwig

Reputation: 20784

You could embed links to the raw data in your JSON responses. For example:

{
   title: 'A Really Big File',
   date: '2011-11-11',
   file: 'http://example.com/really_big_file.xls'
}

That way you can allow clients to decide whether or not they want to dereference the big file or not.

Upvotes: 2

Related Questions