Skip to content
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

[bug] Media upload using Tokodon client fails #1944

Closed
Ghabry opened this issue Jul 5, 2023 · 6 comments
Closed

[bug] Media upload using Tokodon client fails #1944

Ghabry opened this issue Jul 5, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@Ghabry
Copy link

Ghabry commented Jul 5, 2023

Describe the bug with a clear and concise description of what the bug is.

Attaching media files using "Tokodon" fails with invalid request 400.

What's your GoToSocial Version?

main

GoToSocial Arch

No response

What happened?

Tokodon sends media using Content-Disposition: attachment; name="file"; filename="NAME.png"

What gotosocial expects is Content-Disposition: form-data; name="file"; filename="NAME.png"

Patching Tokodon to use form-data fixes the media upload (tested pictures and videos) so this is indeed the issue.

Question is if this is a bug in Tokodon or in gotosocial and how hard it is to implement a workaround in gotosocial.

I have no knowledge in go so I cannot figure it out. No idea how to convince File *multipart.FileHeader form:"file" binding:"required" of AttachmentRequest to accept attachment.

What you expected to happen?

No response

How to reproduce it?

No response

Anything else we need to know?

No response

@Ghabry Ghabry added the bug Something isn't working label Jul 5, 2023
@Ghabry
Copy link
Author

Ghabry commented Jul 5, 2023

Hm and a kinda related issue happens when uploading an avatar or a banner for the profile. Here gotosocial requires this header: Content-Disposition: form-data; name="avatar"; filename="XXXXX" but Tokodon sends Content-Disposition: form-data; name="avatar" without the filename component. This also results in 400.

@tsmethurst
Copy link
Contributor

Hmm, looking at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition makes me think this is likely a bug in Tokodon, since it seems according to the reference that attachment should be used in response headers, not in request headers. Worth opening an issue with Tokodon to get their input too I think.

@Ghabry
Copy link
Author

Ghabry commented Jul 5, 2023

Hm yeah that sounds more like a Tokodon bug.

I will report back when I received any feedback from them if its a bug or not.

The Tokodon code is pretty low level (the requests are just concatenated strings) so fixing this on their side is pretty simple as there is no struct parsing magic etc. xD

@daenney
Copy link
Member

daenney commented Jul 7, 2023

Hm and a kinda related issue happens when uploading an avatar or a banner for the profile. Here gotosocial requires this header: Content-Disposition: form-data; name="avatar"; filename="XXXXX" but Tokodon sends Content-Disposition: form-data; name="avatar" without the filename component. This also results in 400.

This second one is a bug on our side. filename is optional so we should be able to handle the lack of it.

@tsmethurst
Copy link
Contributor

Ah thanks @daenney, i missed that part.

@Ghabry
Copy link
Author

Ghabry commented Jul 8, 2023

The issue was resolved in tokodon. I will open another issue here for the second bug.

@Ghabry Ghabry closed this as not planned Won't fix, can't repro, duplicate, stale Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants