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?


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.


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".

链接地址: http://www.djcxy.com/p/48642.html

上一篇: REST API Design将JSON数据和文件发送到同一请求中的api

下一篇: REST风格的Web服务使用JSON上传/下载大数据