• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Image attribute and REST
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Image attribute and REST


  • Subject: Image attribute and REST
  • From: Kieran Kelleher <email@hidden>
  • Date: Fri, 20 Jul 2012 16:52:28 -0400

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

  • Follow-Ups:
    • Re: Image attribute and REST
      • From: Amedeo Mantica <email@hidden>
    • Re: Image attribute and REST
      • From: Jesse Tayler <email@hidden>
  • Prev by Date: Cocoa REST Client and ERRest
  • Next by Date: Re: Image attribute and REST
  • Previous by thread: Cocoa REST Client and ERRest
  • Next by thread: Re: Image attribute and REST
  • Index(es):
    • Date
    • Thread