i have run through the "trunk" core API spec (and Shindig's PHP code)
to check content upload mechanisms.
i know there is some ongoing discussion about CMIS, but in general it
would be useful to fix the current upload procedure(s) in an
implementable/workable way. To be precise, spec and reference
implementations are now truly inconsistent. my apologies in advance
for this long post but a global cleanup is probably needed here.
the core API spec, section 4, mentions 3 alternatives for uploading
media:
1- two steps: 2 requests: picture, then mediaItem object
2- shortcut: 1 request: picture as body and media item attributes as
request parameters
3- multipart: 1 request: form-data style with mediaItem object and
picture in separate fields
wrt 1, the example request line (POST /album/112233?mediaType=IMAGE
HTTP/1.1) is not consistent with any URI fragment of the Album service
specification in social API server (typically "/albums/" User-Id "/
@self"), nor conceptually with the idea of posting to the album
service to actually post a content (semantically pertinent to the
mediaItem service)
in 2, a similar (wrong) request line is given (POST /album/112233/
mediaitem/?title=Lena&type=IMAGE HTTP/1.1). the type/mediaType
parameter name is also confusing
in 3, an RPC-style mechanism is mentioned, which is reasonable
although it does not specifically refer to the RPC protocol part of
the spec. neither on the other way around section 2.2 of the core api
spec mentions form-data as a possible content-type for this specific
use case. there is no further assumption on how to discover (e.g. from
a gadget) whether this mechanism is supported or not by the server/
container and how to post media (if supported). finally, on the
implementation side shindig does not seem to support form-data on the
rpc endpoint (i can understand this is up to developers)
when looking instead at the mediaItem spec in social api spec (which
seems to be the right place formally), section 2.6.2 suggest to use
POST "/mediaItem/" User-Id "/@self/" Album-Id to create a mediaItem
(without the content itself). the spec mentions "mediaItem" in the uri-
fragment for the POST, whilst all other fragments use
"mediaItems" (plural).
what is interesting is that from the implementation side (still
shindig), there is truly one mechanism supported at this stage for
content upload, which is a mix between this latter spec and
alternative 2 of the content upload section. indeed after some tests
we got POST /mediaitems/112233/@self/1?title=Lena&type=IMAGE HTTP/1.1
working using shindig3, and inserting the raw image as body.
probably the implementation actually got it more right than the spec
itself, and would deserve to be clarified 1) in section 2.6.2 of the
social api spec to formally define this option of media embedding, 2)
in section 4.2 of the core api spec to refer to a correct example.
regarding the other 2 alternative mechanisms, depending on the various
interests, alternative 3 (form-data) may be formally clarified as an
option by adding (optional) support for form-data content-type in the
rpc section 2.2 of the core api spec, whilst alternative 1 would
probably need some more in-depth revision.
i got this from live experience in writing clients to post content to
shindig, but i assume that the spec cleanup would also benefit whoever
is willing to implement such capability in a standard way in an
opensocial-compliant server.
i am available to help if needed with the revision text but would like
to get some comments especially from users who may have already
experienced/implemented content upload with opensocial.
cheers
walter