Re: Image attribute and REST
Re: Image attribute and REST
- Subject: Re: Image attribute and REST
- From: Jesse Tayler <email@hidden>
- Date: Sat, 21 Jul 2012 15:53:24 -0400
of course, every app is different -
but basically…
when it comes down to it --
I ALWAYS separate "text" data from the binary data -first thing- just as a rule of thumb.
I would think that if you encode the binary, you'll not have any trouble vending that data via ERRest, but binary data is just a different animal...
"text" data, by that I mean a representation of a calendar date, number or some text string has a fixed length right? short. but binary is typically a photo or video and each of those is an _order of magnitude_ greater in size potential.
it's a serious difference in bytes!
The binary data doesn't go into the database like this "text" data does, if it does, it has its own table separation - but in reality, this never really happens and I've regretted or changed it later.
So, I don't vend binary data via REST responses, I only send text - like a URL, a filename or key word that is needed to spawn a separate process from the client.
so, it's really just easier to separate first, ask questions later.
if you really need to send binary, or it just works best that way, then send it! but that just never happens for me in real life it seems.
I certainly upload photos as binary data, and even videos using ERRest to post the data - but then I write that blob to the filesystem and keep just a filename or path in the database.
In real-life this methodology also seems to work best.
For instance, iPhone and iPad clients have different screen density, (retina display) they also have different video playback capacity and so forth right?
So, I send the client just a key or URL and it decides to get a 50 pixel icon vs. a 100 pixel icon or an HD video or not, etc.
In this case, I have the server write out as many thumbnail icon sizes or as many video transcodings as could be used, and I let the client request whatever it needs separately. Otherwise what? The client would request different feeds for different file sizes or formats? Binary data is just a different animal!
make sense?
hope that helps!
On Jul 20, 2012, at 9:45 PM, Kieran Kelleher <email@hidden> wrote:
> Hi Jesse,
>
> Yes. This is a REST API served over http(s). :-)
>
> What I have described is working fine. Just wondering what others are doing and if there is a more elegant and/or standard approach.
>
> Regards and thanks, Kieran.
> (Sent from my iPhone)
>
>
> On Jul 20, 2012, at 7:04 PM, Jesse Tayler <email@hidden> wrote:
>
>> 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