U may encode the blob in a base64 and pass it in the rest response. But I think 
is better to pass a plain url and fetch the blob only when required by client.

Amedeo

Sent from my iPhone

On 20/lug/2012, at 22:52, Kieran Kelleher <[email protected]> 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 protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/amedeomantica%40me.com
> 
> This email sent to [email protected]
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to