You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where I have to be explicit about the Content-Type in the multipart part of the POST request, otherwise the server doesn't accept the file. By directly using requests I could use the 3-tuple parameter ('filename', fileobj, 'content_type'), which I've tried and works.
How can I do that with MechanicalSoup StatefulBrowser?
The text was updated successfully, but these errors were encountered:
I don't think there's an easy way other than patching MechanicalSoup, but patches are welcome if it solves a problem.
I'm wondering how this content type can be computed. Just guessed from the local file content? Set by the programmer from the MechanicalSoup API (probably the best option to be realiable), e.g. by allowing browser["file-field"] = (filename, content-type)?
Set by the programmer from the MechanicalSoup API (probably the best option to be realiable), e.g. by allowing browser["file-field"] = (filename, content-type)
That would be perfectly fine and absolutely enough for my use-case. This could even be the preferred way over automagically detecting the file type as this could go wrong and then you're out of luck again. I'm a fan of being able to specify things explicitely.
In https://github.com/MechanicalSoup/MechanicalSoup/blob/master/mechanicalsoup/browser.py#L203 the 2-tuple of the
files
parameter('filename', fileobj)
is used.I have a use case where I have to be explicit about the
Content-Type
in the multipart part of the POST request, otherwise the server doesn't accept the file. By directly usingrequests
I could use the 3-tuple parameter('filename', fileobj, 'content_type')
, which I've tried and works.How can I do that with MechanicalSoup
StatefulBrowser
?The text was updated successfully, but these errors were encountered: