Replies: 4 comments 4 replies
-
First of all, thank you very much for starting this discussion! I appreciate a lot if anybody wants to take part in the development. We definitely want to store the files in the filesystem, because it allows to utilize the web server directly for serving them. It also allows to upgrade to cloud object storage (using JuiceFS, for example) for large workloads. I also think we should separate the files from their relationship with entries (posts and comments). Please note that one server may handle several nodes and these nodes may contain identical media files. We don't want to waste the disk space for keeping identical files. Think of userpics, popular memes, reposts and the newsfeed (that contains copies of posts from other nodes) - all these will create a lot of such duplicates. So we store the media files in the filesystem under the names that are SHA-256 checksum of the file content - such an approach will help us to find duplicates easily. We also should store a table that contains the content-type of every file, its size and some metadata needed - for example, image dimensions. A separate table should keep the list of attachments - Image thumbnails should be stored as separate files and a special table should link them to the full-sized image. Note that there may be several thumbnails for the same file - for different purposes. And also content-type of a thumbnail may differ from the content-type of the original files (think of static previews of GIFs or images previewing PDF files). Thus, creation of an attachment should consist of two steps:
So we don't need a separate API for managing attachments, but we do need an API for managing media files as a separate entity. Feel free to make comments and update your document and we can talk further about smaller things. |
Beta Was this translation helpful? Give feedback.
-
Good point with deduplication, the same attachment might be used for several posts/comments in the same node, and I like the idea of checksum as the canonical media id. It is still useful to have aliases associated with posts for three reasons: (1) it is easier to refer a short alias from markdown; (2) give a way to attach the files without mentioning them in the post, similar to mail attachments; (3) allow deleting the attachments with the post. Owner's name is necessary for attachments as soon as we are going to eventually allow attachments to comments, as well as in communal nodes (groups). |
Beta Was this translation helpful? Give feedback.
-
Consider seeweedfs for storage. Especially good for images. |
Beta Was this translation helpful? Give feedback.
-
Another feature idea regarding attachments, would be Markdown support for referencing attachments using reference style links. The "footnotes" part defining actual links may be implicitly added to each post - so |
Beta Was this translation helpful? Give feedback.
-
Goal
Provide the way to add attachments (pictures, videos etc) to the posting.
Possible extension of adding attachments to comments is not discussed here.
Node interface
The node may reject attachment posting based on content type, length etc.
Data types
REST API extension
PUT /postings/{id}/attachment
- put new attachment and autogenerate nameHeaders: Content-type, Content-encoding, Content-length
Body: the blob, optionally encoded with passed encoding
Returns:
AttachmentMetadata
PUT /postings/{id}/attachment/{name}
- put attachment with given name, or replace existing attachment.{name}
is expected to be filename with extension in usual filesystem style, case sensitiveHeaders: Content-type, Content-encoding, Content-length
Body: the blob, optionally encoded with passed encoding
Returns:
AttachmentMetadata
GET /postings/{id}/attachment_list
- get list of attachments for the postGET /postings/{id}/attachment/{name}[/{revision}]
- get AttachmentMetadata. The latest revision by defaultGET /postings/{id}/attachment/{name}[/{revision}]/blob
- get attachment blobDatabase
Do we want the blob in postgre or in filesystem?
UI
The Markdown image link
!(foo)[filename.ext]
is referring to the attachment to current post. The uninterpreted attachments are represented as download links below the posting text.Beta Was this translation helpful? Give feedback.
All reactions