的WebAPI:如何处理图像 [英] WebApi: How to handle Images

查看:296
本文介绍了的WebAPI:如何处理图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我旋转起来我第一次的WebAPI应用程序,我对如何处理图像的2个问题。

I am spinning up my 1st WebApi application and I have 2 questions about how to deal with images.

1)什么是不同的方式来POST / GET图片到我的服务?我想我可以使用的Base-64文本JSON或保持原生二进制。我的理解是由图像转换成文字,还有一个显著增加封装尺寸。

1) What are the different ways to POST/GET images to my service? I think I can either use Base-64 text in JSON or stay native as binary. My understanding is that by converting the image into text, there is a significant increase is package size.

2)如果我发送图像(通过Web的形式,从本地客户端,从其他服务),我应该添加一个图像打印控制器/处理器或使用格式化?这甚至是要么/或问题?

2) If I send the image (from a web form, from a native client, from another service), should I add a Image Controller/Handler or use a Formatter? Is this even an either/or question?

我研究计算器和谷歌有很多的例子上来:

I have researched StackOverflow and Google and came up with lots of examples:

图像服务(POST)
  控制器:结果
  <一href=\"http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2\">http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2
  <一href=\"http://$c$c.msdn.microsoft.com/Uploading-large-files-386ec0af#content\">http://$c$c.msdn.microsoft.com/Uploading-large-files-386ec0af#content

格式化: http://jflood.net/tag/mediatypeformatter/

图像从服务(GET)
  控制器:
  <一href=\"http://www.dotnetcurry.com/ShowArticle.aspx?ID=856\">http://www.dotnetcurry.com/ShowArticle.aspx?ID=856
   ASP的.NET Web API下载图像为二进制
  <一href=\"http://www.strathweb.com/2013/01/asynchronously-streaming-video-with-asp-net-web-api/\">http://www.strathweb.com/2013/01/asynchronously-streaming-video-with-asp-net-web-api/
  格式化:结果
  <一href=\"http://www.asp.net/web-api/overview/formats-and-model-binding/media-formatters\">http://www.asp.net/web-api/overview/formats-and-model-binding/media-formatters

图像,并从
  控制器:
  <一href=\"http://www.$c$cguru.com/csharp/.net/returning-images-from-asp.net-web-api.htm\">http://www.$c$cguru.com/csharp/.net/returning-images-from-asp.net-web-api.htm

格式化程序:
  <一href=\"http://byterot.blogspot.com/2012/04/aspnet-web-api-series-part-5.html\">http://byterot.blogspot.com/2012/04/aspnet-web-api-series-part-5.html

我不知道我应该走向哪个方向。是一个网站/博客文章中,规定了这样做的利弊?而且我还没有看的WebAPI V2,看看是否有不同的方式来思考这个问题。

I am not sure which direction I should be heading. Is the a site/blog article that lays out the pros and cons for this? And I haven't even looked at WebApi V2 to see if that has a different way to think about this.

在此先感谢

推荐答案

我做了一些研究,你可以看到,我想出了这里的实现:<一href=\"http://jamessdixon.word$p$pss.com/2013/10/01/handling-images-in-webapi/\">http://jamessdixon.word$p$pss.com/2013/10/01/handling-images-in-webapi/

I did some research and you can see the implementation I came up with here: http://jamessdixon.wordpress.com/2013/10/01/handling-images-in-webapi/

这篇关于的WebAPI:如何处理图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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