5

I am creating a RESTful web service and some of the resources are computing or processing functions. For instance, it is possible for a user to scale and convert images through the API by submitting an image and receiving the scaled or converted image back.

According to the RESTful Web Services Cookbook, section 2.5, I should use GET:

Treat the processing function as a resource, and use HTTP GET to fetch a
representation containing the output of the processing function. Use query
parameters to supply inputs to the processing function.

This is clear for cases where the inputs are simple (such as the long/lat coordinates of a point). However, should I follow the same advice for larger inputs such as images? As far as I know it is not possible to send this much data as a query parameter.

Mauritz Hansen
  • 4,674
  • 3
  • 29
  • 34

4 Answers4

6

Use POST. In effect you are doing an Image Upload and processing on the server. Can't think of another way to do it unless the image is already stored on the server.

Sid
  • 7,511
  • 2
  • 28
  • 41
  • This is the important notion here: "the image is already stored on the server." Whether to get it there with PUT or POST is a [different question](http://stackoverflow.com/questions/630453/put-vs-post-in-rest). – kdbanman Jun 24 '15 at 22:26
1

The image is a resource. Use PUT to put the resource on the server, then GET the resource, supplying parameters indicating your desired size.

Jim
  • 72,985
  • 14
  • 101
  • 108
  • Wow, this is quite thought provoking! – sivabudh Apr 01 '13 at 08:47
  • 1
    Use `PUT` if only the client submits image IDs as part of the request. Use `POST` if the server generates image IDs and returns them on success. Google "REST idempotency", or see [this question](http://stackoverflow.com/questions/630453/put-vs-post-in-rest) – kdbanman Jun 24 '15 at 22:21
  • what if we are concerned about storage? then we cannot save the data, and then PUT does not make sense – cammil Feb 18 '16 at 16:11
0

Due to protocol limitations on HTTP I advice against it. This is a very valid very viable example of an exception that should be made to this rule.

MahdeTo
  • 11,034
  • 2
  • 27
  • 28
0

Check out this link http://support.microsoft.com/default.aspx?scid=KB;en-us;q208427. It says that the maximum URL for IE is 2083 characters

Orin
  • 351
  • 5
  • 13