-
Notifications
You must be signed in to change notification settings - Fork 36
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
Allow Async (v2) Uploads to Mastodon for bigger files (Videos); GET M… #116
base: main
Are you sure you want to change the base?
Conversation
What happens if we try to attach the media id on a post before the media is actually available ? |
@glacasa trying to use the Media in a toot before it is completely processed just throws a general Error (HTML-Page, "Something went wrong on our site") (at least on the mastodon.social instance) Nonetheless I didn't include the waiting in the upload itself but only on the example, because there might be reasons to not wait for it. (e.g. uploading multiple files etc.) |
It seems there's been a change to how media uploads are handled between v2 and v3 of mastonet, now I get "Cannot attach files that have not finished processing. Try again in a moment!" and there's no corresponding media get api call implemented (it returns 206 while media is being processed), so we need that first, and maybe a wrapper like the one proposed here for convenience. |
@13xforever Did you call the "WaitUntilMediaIsUploaded()" method before trying to create the toot? |
No, I did not. I simply upgraded the client and didn't change any code as there's no guidance or mention of any breaking changes anywhere I could see. EDIT: also I just checked and there's no |
@13xforever Sorry, but I suspect you are in the wrong issue here. What we discuss here is a change that hasn't even been merged yet. I suggest you open a different issue for your problem. |
What I'm saying is that there's an issue with media uploads right now because of the missing api implementation, and this particular PR is a hacky workaround for it and maybe it's worth to consider proper implementation with something similar built on top of that, and not pulling this as is. Not only this method will be hard to discover (it's not directly under the media apis, and sits directly on the client class), it's also solving a very specific issue that's already provided by the new mastodon api, and following closer to the specification will help with discoverability (especially considering this library lacks in docs and examples at the moment). |
Hello, thanks to both of you. If something was broken, could you open a new issue @13xforever ? Once this fixed, I will look if we still need to handle processing like this. |
Added V2-Upload
The V1 - Upload is only meant for smaller images and does not work with bigger files like Videos. The (now recommened) V2 Upload takes any attachment and does all work asynchronously in the background. While this happens the attachmentID is already returned but can not yet be used on a toot.
That is why I also added a poll mechanism to wait for the processing to be finished.
Example for usage: