RESTful Web服务使用JSON上传/下载大数据 [英] RESTful Web Service Upload/Download Large Data With JSON

查看:593
本文介绍了RESTful Web服务使用JSON上传/下载大数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果要实现将向客户端发送大文件或从客户端接收大文件的Web服务,最佳实践是什么.通常,我们正在发送JSON对象,但是如果我们在JSON对象中包含较大的数据有效负载,则可能会出现问题.我们需要提供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?

推荐答案

您可以将指向原始数据的链接嵌入JSON响应中.例如:

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.

这篇关于RESTful Web服务使用JSON上传/下载大数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆