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

Specifying file mime type for multipart requests using python requests module #302

Open
Accumulative opened this issue Sep 2, 2022 · 1 comment

Comments

@Accumulative
Copy link

I'm unable to specify the mime type of the files sent as part of multipart/form-data requests using the python requests module.

I believe the relevant code is here: https://github.com/Kong/httpsnippet/blob/master/src/targets/python/requests/client.ts#L82

I was thinking we could support it by making a change like so:

if (p.fileName) {
  if (p.mimeType) {
     files[p.name] = `('${p.fileName}', open('${p.fileName}', 'rb'), '${p.mimeType}')`;
  } else {
     // current behaviour
     files[p.name] = `open('${p.fileName}', 'rb')`;
  }
  hasFiles = true;
} else {
  payload[p.name] = p.value;
  hasPayload = true;
}
@joebullard
Copy link

bump

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