REST API文件上传 [英] REST API File Upload

查看:334
本文介绍了REST API文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了一些Web服务,并自己制作了服务.所有这些都很简单,并且只使用像这样的简单GET请求:

I used some web services and made my own. All of them were simple and they were only using simple GET requests like this:

http://foobar.com/api/movies?category=drama& apikey = bsbsbsbsbs

,并根据提供的参数输出JSON数据.

and a JSON data was output according to the parameters provided.

我想做的是文件上传服务.通常,如果它不是Web服务,我将为此使用HTTP POST.如何使用REST API做到这一点?关于REST Web服务,POST和GET请求之间有什么区别.

What I wanna do is a fileupload service. Normally if it wasn't a web service I would use HTTP POST for this. How can i do this with REST API? What's the difference between POST and GET requests with respect to REST web services.

我正在使用PHP,请不要提供ASP.net示例.

I'm using PHP, please don't give ASP.net examples.

推荐答案

在REST中,如果您要上传文件,则可以使用CRUD方法(创建,读取,更新,删除). PUT( Update )或POST( Create )方法. GET( Read )仅用于从您的服务获取数据,而不能用于创建,更新和删除.

In REST you have the CRUD Methods ( Create, Read, Update, Delete) if you want to upload a file you need a PUT(Update) or POST(Create) method. The GET (Read) is only to get data from your Service not for Create, Update, Delete.

在这里您将获得更多信息

Here you will get some more information

http://www.ibm.com/developerworks/library/ws- restwsdl/

REST PHP示例:

REST PHP Example:

http://coreymaynard.com/blog/creating- a-restful-api-with-php/

这篇关于REST API文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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