Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Octect-stream representation of a resource
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nicolas Faugout  
View profile  
 More options Nov 13 2012, 4:38 am
From: Nicolas Faugout <nfaug...@lucca.fr>
Date: Tue, 13 Nov 2012 01:38:44 -0800 (PST)
Local: Tues, Nov 13 2012 4:38 am
Subject: Octect-stream representation of a resource

We are implementing de REST API with resources names "files".

/api/files.json returns the list of files such as user pictures, blog posts
attachments, etc..

/api/files/123.json returns file number 123 in JSON format.

A file contains fields such as "name", "id", "author", "lastmodified", etc..

How should I implement the fact that a file could be downloaded ?

I have several options :

1. the octect-stream representation of the file resource can be considered
similar to the JSON and XML ones, so I can make /api/files/123.data to get
the stream of the file

2. all of my resources have a "url" attribute that points to their API URL,
but I could make an exception for the "files", for whom the url coud refer
to the downloadable version of the file, like so : { "file": { "id": 123,
"url": "/getFile.ashx?id=123" } } but I don't like this approach

3. Any other idea is welcomed !

Thanks a lot.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
chris.d...@gmail.com  
View profile  
 More options Nov 13 2012, 5:57 am
From: chris.d...@gmail.com
Date: Tue, 13 Nov 2012 10:57:03 +0000 (GMT)
Local: Tues, Nov 13 2012 5:57 am
Subject: Re: [api-craft] Octect-stream representation of a resource

On Tue, 13 Nov 2012, Nicolas Faugout wrote:
> 1. the octect-stream representation of the file resource can be considered
> similar to the JSON and XML ones, so I can make /api/files/123.data to get
> the stream of the file

Something like this.

Would be best if your API (and browsers, dammit!) supported effective
use of Accept headers so that /api/files/123 could be the uri for
several different representations. The ability to use extensions is a
nice addition for friendly human browsing of representations, but
should be an addition, not a requirement.

--
Chris Dent                                   http://burningchrome.com/
                                 [...]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicolas Faugout  
View profile  
 More options Nov 13 2012, 6:23 am
From: Nicolas Faugout <nfaug...@lucca.fr>
Date: Tue, 13 Nov 2012 03:23:42 -0800 (PST)
Local: Tues, Nov 13 2012 6:23 am
Subject: Re: [api-craft] Octect-stream representation of a resource

Thanks for the quick answer.

I had thought of the Accept HTTP Header as well, so I will stick with that.

Do you think that the default representation could be contextual to the
type of resource ?

For instance, /api/users/123 returns by default the JSON representation
whereas /api/files/123 returns the octect-stream one ?

This way, within a browser, one could be able to :
- download the file with /api/files/123
- see the file info with /api/files/123.json
- see user info with /api/users/123 or /api/users/123.json

Thanks in advance.

Le mardi 13 novembre 2012 11:57:30 UTC+1, Chris Dent a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
chris.d...@gmail.com  
View profile  
 More options Nov 13 2012, 6:37 am
From: chris.d...@gmail.com
Date: Tue, 13 Nov 2012 11:36:45 +0000 (GMT)
Local: Tues, Nov 13 2012 6:36 am
Subject: Re: [api-craft] Octect-stream representation of a resource

On Tue, 13 Nov 2012, Nicolas Faugout wrote:
> Do you think that the default representation could be contextual to the
> type of resource ?

I personally think so, yes, but I'm not sure that's a consensus among
all the participants in this group.

It can lead to a bit of confusion as people tend to expect a measure
of consistency.

<troll aspect="lighthearted">
I'm sure the HATEOAS fans will say that effective use of hypermedia
alleviates the confusion by controlling the expectations. While I
think this is a fine idea, it's less true in practice when the
audience is a) human b) boundless.
</troll>

--
Chris Dent                                   http://burningchrome.com/
                                 [...]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicolas Faugout  
View profile  
 More options Nov 13 2012, 7:50 am
From: Nicolas Faugout <nfaug...@lucca.fr>
Date: Tue, 13 Nov 2012 04:49:59 -0800 (PST)
Local: Tues, Nov 13 2012 7:49 am
Subject: Re: [api-craft] Octect-stream representation of a resource

Thank you for your advice.

Have a nice day.

Le mardi 13 novembre 2012 12:37:01 UTC+1, Chris Dent a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »