Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSC2246: Asynchronous media uploads #2246
MSC2246: Asynchronous media uploads #2246
Changes from 27 commits
b439277
a83c79c
9a395ed
29e3463
7cf22be
658aac8
bbd7d08
0bffcb7
4d009a9
1cbc04e
c65f2bf
63cef50
8ccf85f
12e907b
d582bb3
173edf3
f438754
725675c
d55f1f9
955177b
823fcca
3b00026
9627af2
045c21e
011031b
6cb7e31
fedc697
7652f59
098dd90
9559ab0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intention that this endpoint support the
content-type
header andfilename
query parameter, as https://spec.matrix.org/v1.6/client-server-api/#post_matrixmediav3upload does? It looks like the sample implementation at https://github.com/turt2live/matrix-media-repo/pull/364/files#diff-3ddbc505e50723b8440369eef4dc1fa055026668151b1dbecbd1725fc6765727 does, but this isn't mentioned in the MSC.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. In the future those details could be moved to the /create call request body, but that wasn't defined here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the upload fails but the bridge has already sent the message containing the MXC URI? This might need some more detail on exactly how multiple calls to the endpoint work, although it's been touched on in other comments.
To throw a few ideas out:
For concurrent uploads, could leave it up to the HS to decide how to handle sensibly, possibly advising that later uploads kick off any started earlier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, as the person currently holding this MSC up, I'm not too concerned with this case. The two most likely scenarios are:
The http client can't hit the server for some reason. If the call is interrupted or otherwise has a connection error then the upload can/should be cancelled/invalidated. Similarly, most http clients buffer a good portion of the request (and when they don't, http servers tend to do a lot of buffering at the application level): this buffering means that even if the client doesn't see the response the upload is still likely to be successful.
The server encounters an error during the processing of the upload. In this case, the server should reject the http request with a 500 or similar error and not consider any potentially-partial content as uploaded.
There's certainly an argument for improved error handling though - I'll leave that to @dbkr & others to decide if it warrants an
@mscbot concern
comment :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, this is sort of an implied feature from most sane media repo implementations: it's quite rare that a server ever wants to buffer the media into memory so will stream it from a cache, disk, or external service as it receives the data. By extension, they already will have had to figure out what stream interruption, multiple workers, etc means. However, clients obviously shouldn't rely on this functionality existing, but I also don't think it necessarily needs an MSC either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this paragraph has some hidden history, this is a change from the original requirement (include streaming) after I commented about some security concerns here.
TLDR: it's not as much about being able to stream, but that the file is mutable and uncommitted while it's streamed, that there's an edge case where; if a client closes the upload stream, starts again, but then uploads a wholly different file, how should everything then fail/proceed gracefully to accommodate this new situation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that sounds like a thing we should fix as part of this MSC regardless, to be honest. Does a partial failed upload count as uploading the media? (ie: does the server mark the media as "uploaded" at the start or the request handling or at the end?) what happens if the client tries to upload the media twice (concurrently)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also poked at the "partial uploads" problem here; imo, there shouldn't be partial uploads, and the client should send
content-length
in the request body to have the server make sure it received everything before it commits the file.Concurrent uploading is something I hadn't considered.