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?
Asked
Active
Viewed 6,806 times
2 Answers
2
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.

Steven Huwig
- 20,015
- 9
- 55
- 79
-
Steve, thank you, that sounds great for the download side. But what if a client wants to upload a file but also needs to send JSON data to go with it. – Anthony Nov 14 '11 at 21:51
-
Oh , I found this nice post: http://stackoverflow.com/questions/4083702/posting-a-file-and-data-to-restful-webservice-as-json – Anthony Nov 14 '11 at 21:57
0
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".

Vladislav Bauer
- 952
- 8
- 19