Re: Image attribute and REST
Re: Image attribute and REST
- Subject: Re: Image attribute and REST
- From: Jesse Tayler <email@hidden>
- Date: Fri, 20 Jul 2012 19:04:56 -0400
of course, you are certain the data itself has to be sent via REST at all? not simply via http?
On Jul 20, 2012, at 4:52 PM, Kieran Kelleher <email@hidden> wrote:
> Just curious how others are handling image (blob/binary) attributes in REST responses.
>
> For example, I have a REST EO named Media that has a blob attribute key 'content', typically containing an image. The Media entity also has the mime type, image dimensions, etc as attributes.
>
> What I did was omit the 'content' key from the response and added an additional direct action named contentAction to the MediaController class that simply returns the object itself as a response content with the appropriate mime type.
>
> For example, a url like this for the Media object
> https:// .......... /Media/28747.xml
>
> returns sth like this:
> <CTMedia id="28747" objectType="Media">
> <mimeType>image/jpeg</mimeType>
> <pixelHeight type = "integer">825</pixelHeight>
> <pixelWidth type = "integer">1275</pixelWidth>
> </CTMedia>
>
> And to get the actual blob...
> https:// .......... /Media/28747/content
>
> Extensions such as .xml or.json on the url are ignored since response content-type header will reflect the mime type.
>
> Is there other approaches you guys are using, or even other "standard" approaches for handling binary attributes in REST responses? For example, should a derived attribute be added to the object response to indicate the URL..... sth like this??
>
> <CTMedia id="28747" objectType="Media">
> <content type="url">/app/Media/28747/content</mimeType>
> <mimeType>image/jpeg</mimeType>
> <pixelHeight type = "integer">825</pixelHeight>
> <pixelWidth type = "integer">1275</pixelWidth>
> </CTMedia>
>
> Thoughts?
>
> -Kieran
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden