English 中文(简体)
如何通过JSON 发送一个PDF文件 发送到我的客户
原标题:How to send a PDF file via JSON from my REST Service to my clients
  • 时间:2012-05-25 18:58:57
  •  标签:
  • json
  • rest

是否有可能在 JSON 中发送二进制数据? 我正在在 ASP. NET MVC 中创建 REST Service 。 我想将存储在我的服务器中的 PDF 文件还给我的客户 。 我将怎么做呢? 我的数据传输介质是 JSON & amp; XML 。

问题回答

看看这里:"http://www. thinkingcode.info/2015/05/how-to-send-pdf-in-json/" rel="no follow" 如何发送 pdf injson ,它列出了几种你可以考虑的方法。

最简单的方式是使用 Base64 编码将二进制数据转换为字符串。 在 C# 中, 这将意味着调用 < code> Convert. fromBase64String 。 但是, 使用 Base64 编码意味着增加 33% 的内存 。

如果您可以逃脱, 这是最不复杂的解决方案。 万一额外大小是问题, 您可以考虑把它拉上拉链 。

如果您需要 JSON 或 XML 包装文件, 您需要文本编码, 例如 Base 64 。





相关问题
Allow RESTful DELETE method in asp.net mvc?

im currently setting up asp.net to accept DELETE http verb in the application. However, when i send "DELETE /posts/delete/1" i always get a 405 Method not allow error. I tried to take a look at ...

Most appropriate API for URL shortening service

I ve just finished an online service for shortening URLs (in php5 with Zend Framework); you can enter an URL and you get an short URL (like tinyurl and such sites). I m thinking about the API for ...

Use HTTPClient or HttpUrlConnection? [closed]

We re implementing a REST client on JRE 1.4. Seems two good options for a client REST framework are HttpClient and HttpUrlConnection. Is there a reason to use HttpClient over the JRE s ...

Why can t I find the truststore for an SSL handshake?

I m using the Spring RESTTemplate on the client side to make calls to a REST endpoint. The client in this case is a Spring app and Tomcat is the servlet container. I m running into issues making a ...

Which Http redirects status code to use?

friendfeed.com uses 302. bit.ly uses 301. I had decided to use 303. Do they behave differently in terms of support by browsers ?

Three Step Buyonline The RESTful way

We are re-developing our buyonline functionality and we are doing it the RESTful way. The process is a three step one and the customer is asked to enter data at each step. Let s say the three URL s ...

热门标签