diff options
author | Max Wittig <max.wittig@siemens.com> | 2020-12-16 14:27:48 +0100 |
---|---|---|
committer | Max Wittig <max.wittig@siemens.com> | 2021-01-28 08:46:51 +0100 |
commit | 2fa3004d9e34cc4b77fbd6bd89a15957898e1363 (patch) | |
tree | 79b0127e030c30b919b02facd1d6bccfe49d7f0b /gitlab/__init__.py | |
parent | fd179d4f88bf0707ef44fd5e3e007725a0331696 (diff) | |
download | gitlab-feat/multipart-uploads.tar.gz |
feat: support multipart uploadsfeat/multipart-uploads
Diffstat (limited to 'gitlab/__init__.py')
-rw-r--r-- | gitlab/__init__.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 960f086..98c4144 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -27,9 +27,11 @@ import gitlab.config from gitlab.const import * # noqa from gitlab.exceptions import * # noqa from gitlab import utils # noqa +from requests_toolbelt.multipart.encoder import MultipartEncoder + __title__ = "python-gitlab" -__version__ = "2.5.0" +__version__ = "2.6.0" __author__ = "Gauvain Pocentek" __email__ = "gauvainpocentek@gmail.com" __license__ = "LGPL3" @@ -496,9 +498,11 @@ class Gitlab(object): # We need to deal with json vs. data when uploading files if files: - data = post_data json = None - del opts["headers"]["Content-type"] + post_data["file"] = files.get("file") + post_data["avatar"] = files.get("avatar") + data = MultipartEncoder(post_data) + opts["headers"]["Content-type"] = data.content_type else: json = post_data data = None @@ -509,9 +513,7 @@ class Gitlab(object): # The Requests behavior is right but it seems that web servers don't # always agree with this decision (this is the case with a default # gitlab installation) - req = requests.Request( - verb, url, json=json, data=data, params=params, files=files, **opts - ) + req = requests.Request(verb, url, json=json, data=data, params=params, **opts) prepped = self.session.prepare_request(req) prepped.url = utils.sanitized_url(prepped.url) settings = self.session.merge_environment_settings( |