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

Feature Request: Uploading Files #19

Open
WillNilges opened this issue Aug 6, 2023 · 1 comment
Open

Feature Request: Uploading Files #19

WillNilges opened this issue Aug 6, 2023 · 1 comment

Comments

@WillNilges
Copy link

Big fan of this library. Is there any chance you might add a way to upload files?

@cgt
Copy link
Owner

cgt commented Aug 7, 2023

Thank you. Have you had a look at the MediaWiki API docs for uploading files? https://www.mediawiki.org/wiki/API:Upload I think the Post method would work fine for making upload requests. The only caveat is that file uploads must be sent as multipart/form-data and go-mwclient only uses that format for requests with sufficiently large (>8K) fields. If you try to upload an image smaller than that, it would try to send the request as application/x-www-form-urlencoded. Perhaps working around this issue would be a good reason to add a special method for uploading files to go-mwclient. Alternatively, I could change it to always use multipart/form-data for POST requests. I don't see any downsides to doing that. Still, it could be useful to have a method like Upload(params params.Values, file io.Reader) error as a convenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants