Is it possible to return application / octet stream from REST interface?

Am I breaking any laws in the REST Bible by returning an application / octet stream for my answers? The REST endpoint receives 5 image URLs.

{ "image1": "http://ww.o.com/1.gif",
  "image2": "http://www.foo.be/2.gif" }

and it will load them and return them as an application / octet stream.

CLARIFICATION . The client that invokes this REST interface is a mobile application. All additional network connections reduce battery life by a few milliamps. I have to use REST because it is the standard of the company. If not, I will make my own binary protocol.

+3
source share
4 answers

, , , - - ( , , ).

multipart . IMO, , image/gif, .

+2

, RPC. , " URL-, ".

RESTful, REST RPC.

, , .

, :

POST /archives
Content-Type: application/json

{ "image1": "http://ww.o.com/1.gif",
  "image2": "http://www.foo.be/2.gif" }

HTTP/1.1 201 Created
Location: http://example.com/archives/1234
Content-Type: application/json

http://example.com:

GET /archives/1234
Accept: multipart/mixed

( ), . (multipart/x-zip , zip )

:

GET /archives/1234
Accept: application/json

JSON, ( , , , -, , , ).

, :

PUT /archives/1234
Content-Type: application/json

{ "image1": "http://ww.o.com/1.gif",
  "image2": "http://www.foo.be/2.gif",
  "image3": "http://www.foo2.foo/4.gif" }

//1234, .

: JSON . , Accept. - , , .

,

DELETE /archives/1234

.

+2

REST?

. , 2 .

+1

REST, , , IMO. REST - , URL- ( ) . , . , REST .

, @Andrey , , adhoc-. Multipart mimeType/format - , - , tar, zip .

. "application/octet-stream" , , . , "", , . - () , , , , .

0

Source: https://habr.com/ru/post/1720527/


All Articles