michaelcpuckett / activity-kit

An attempt to build a spec-compliant ActivityPub core library.
MIT License
96 stars 5 forks source link

(outbox:upload-media) Accepts Uploaded Media in submissions [MUST] #2

Closed michaelcpuckett closed 1 year ago

michaelcpuckett commented 1 year ago

https://w3c.github.io/activitypub/#uploading-media

Servers MAY support uploading document types to be referenced in activites, such as images, video or other binary data, but the precise mechanism is out of scope for this version of ActivityPub. The Social Web Community Group is refining the protocol in the ActivityPub Media Upload report.

https://www.w3.org/wiki/SocialCG/ActivityPub/MediaUpload

The Media Upload mechanism defines a protocol for ActivityPub servers to support uploading document types to be referenced in activites, such as images, video or other binary data. To accomplish this, a client MUST submit a multipart/form-data message to the user's uploadMedia endpoint on their ActivityStreams profile object. (Unlike most client to server interactions, using this endpoint does not involve submitting to the outbox). A client should expect that it must be properly authenticated in order to be able to upload media.

The uploadMedia endpoint is part of the ActivityPub endpoints mapping. See ActivityPub extensions.

The submitted form data should contain two parts / fields:

file: The media file file being uploaded. object: A shell of an ActivityStreams object, which will be finalized by the server.

Assuming that the server accepts the request and that the user was appropriately authorized to upload media, servers MUST respond with a 201 Created if the object is immediately available or a 202 Accepted if the server is still processing the submitted media. The response MUST contain a Location header pointing to the new or to-be-created object's id.

The server, having done any appropriate processing on the received file and putting it in place, transforms the object that will be retrievable by the id. In particular, servers MUST append an id property to the object, and SHOULD include the uploaded and/or processed file paths in the object's url property. The server MAY wrap the shell object submitted by the user in a Create via (object-without-create) if appropriate and present this as the object pointed to by the forementioned Location header in the post-media-upload response.

michaelcpuckett commented 1 year ago

This will require a new adapter type/layer (Storage) and an initial adapter (likely S3 or Firebase).

michaelcpuckett commented 1 year ago

Added the generalized Storage layer.

Looking into an appropriate adapter.

I'm not very familiar with hosting/storage/CDN stuff, so I've been looking into various options for my personal site. I haven't had great experiences with Amazon S3 or Google Cloud.

michaelcpuckett commented 1 year ago

I did add a firebase-storage package but I may remove it.

michaelcpuckett commented 1 year ago

Finishing up a general FTP adapter.