Skip to content

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

Description

@Accumulative

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;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions