| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fd179d4 commit 2fa3004
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,9 +27,11 @@ | |||
| 27 | 27 | from gitlab.const import * # noqa | |
| 28 | 28 | from gitlab.exceptions import * # noqa | |
| 29 | 29 | from gitlab import utils # noqa | |
| 30 | + from requests_toolbelt.multipart.encoder import MultipartEncoder | ||
| 31 | + | ||
| 30 | 32 | ||
| 31 | 33 | __title__ = "python-gitlab" | |
| 32 | - __version__ = "2.5.0" | ||
| 34 | + __version__ = "2.6.0" | ||
| 33 | 35 | __author__ = "Gauvain Pocentek" | |
| 34 | 36 | __email__ = "gauvainpocentek@gmail.com" | |
| 35 | 37 | __license__ = "LGPL3" | |
@@ -496,9 +498,11 @@ def http_request( | |||
| 496 | 498 | ||
| 497 | 499 | # We need to deal with json vs. data when uploading files | |
| 498 | 500 | if files: | |
| 499 | - data = post_data | ||
| 500 | 501 | json = None | |
| 501 | - del opts["headers"]["Content-type"] | ||
| 502 | + post_data["file"] = files.get("file") | ||
| 503 | + post_data["avatar"] = files.get("avatar") | ||
| 504 | + data = MultipartEncoder(post_data) | ||
| 505 | + opts["headers"]["Content-type"] = data.content_type | ||
| 502 | 506 | else: | |
| 503 | 507 | json = post_data | |
| 504 | 508 | data = None | |
@@ -509,9 +513,7 @@ def http_request( | |||
| 509 | 513 | # The Requests behavior is right but it seems that web servers don't | |
| 510 | 514 | # always agree with this decision (this is the case with a default | |
| 511 | 515 | # gitlab installation) | |
| 512 | - req = requests.Request( | ||
| 513 | - verb, url, json=json, data=data, params=params, files=files, **opts | ||
| 514 | - ) | ||
| 516 | + req = requests.Request(verb, url, json=json, data=data, params=params, **opts) | ||
| 515 | 517 | prepped = self.session.prepare_request(req) | |
| 516 | 518 | prepped.url = utils.sanitized_url(prepped.url) | |
| 517 | 519 | settings = self.session.merge_environment_settings( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1615,7 +1615,7 @@ def import_group(self, file, path, name, parent_id=None, **kwargs): | |||
| 1615 | 1615 | Returns: | |
| 1616 | 1616 | dict: A representation of the import status. | |
| 1617 | 1617 | """ | |
| 1618 | - files = {"file": ("file.tar.gz", file)} | ||
| 1618 | + files = {"file": ("file.tar.gz", file, "application/octet-stream")} | ||
| 1619 | 1619 | data = {"path": path, "name": name} | |
| 1620 | 1620 | if parent_id is not None: | |
| 1621 | 1621 | data["parent_id"] = parent_id | |
@@ -5488,8 +5488,8 @@ def import_project( | |||
| 5488 | 5488 | Returns: | |
| 5489 | 5489 | dict: A representation of the import status. | |
| 5490 | 5490 | """ | |
| 5491 | - files = {"file": ("file.tar.gz", file)} | ||
| 5492 | - data = {"path": path, "overwrite": overwrite} | ||
| 5491 | + files = {"file": ("file.tar.gz", file, "application/octet-stream")} | ||
| 5492 | + data = {"path": path, "overwrite": str(overwrite)} | ||
| 5493 | 5493 | if override_params: | |
| 5494 | 5494 | for k, v in override_params.items(): | |
| 5495 | 5495 | data["override_params[%s]" % k] = v | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1 +1,2 @@ | |||
| 1 | 1 | requests==2.24.0 | |
| 2 | + requests-toolbelt>=0.9.1 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,7 +26,7 @@ def get_version(): | |||
| 26 | 26 | license="LGPLv3", | |
| 27 | 27 | url="https://github.com/python-gitlab/python-gitlab", | |
| 28 | 28 | packages=find_packages(), | |
| 29 | - install_requires=["requests>=2.22.0"], | ||
| 29 | + install_requires=["requests>=2.22.0", "requests-toolbelt>=0.9.1"], | ||
| 30 | 30 | python_requires=">=3.6.0", | |
| 31 | 31 | entry_points={"console_scripts": ["gitlab = gitlab.cli:main"]}, | |
| 32 | 32 | classifiers=[ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments