Open Zegnat opened 6 years ago
It's worth pointing out that the Micropub specification already advises providing Link headers in the response when creating a post or other microformats2 object that has several URLs:
If the target also provides a shortlink, or if it syndicated the post to another location, the Micropub endpoint may return additional URLs using the HTTP Link header, along with an appropriate "rel" value. For example, it can return the short URL of a post by responding with:
Link: <http://aaron.pk/xxxxx>; rel="shortlink"
or can include the location of the syndicated post with:
Link: <https://myfavoritesocialnetwork.example/aaronpk/xxxxxx>; rel="syndication"
Providing alternative formats and sizes as Links on the media endpoint response isn't quite the same thing, but it does seem to fit quite well. 😄
Background
This is a spin-off from a question by @00dani:
@kevinmarks gives another example of server-side variant generation:
Proposal
I would propose allowing the media endpoint to return alternative variants alongside the uploaded resource as follows:
This could be extended with the
sizes
parameter, following the HTML Standard for its value, though I am not 100% sure how compatible this is with HTTP standards:The client may then check if more appropriate variants have been made available by the server. And as per normal the media endpoint may chose to purge any files that are left unused.
The addition of
Link
headers to the response is 100% backwards compatible with the current specification.Reference specifications
According to RFC 7231 it is fine for a server to return a 201 Created response when “one or more” files have been created. This response may contain “links” to those files. It may then define several URLs within the response as long as the primary file “is identified by […] a
Location
header”. By having theLocation
header always point to the uploaded file it is easy to comply with this.There is no specification for how to link to the alternative files, but there is a note for 300 Multiple Choices that I’ve taken inspiration from: