Skip to content

Commit

Permalink
fix: do not send full filepath as filename in an image upload
Browse files Browse the repository at this point in the history
  • Loading branch information
urubens authored and waliens committed Apr 3, 2024
1 parent 95dbfc5 commit ce65e6a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cytomine/cytomine.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,12 @@ def get(self, uri, query_parameters=None):

def get_model(self, model, query_parameters=None):
response = self._get(model.uri(), query_parameters)

if response.status_code == requests.codes.ok:
response_json = response.json()
model = model.populate(response_json)
self._log_response(response, model)

if not response.status_code == requests.codes.ok:
self._log_response(response, model.uri())
model = False
Expand Down Expand Up @@ -679,8 +679,9 @@ def upload_image(self, upload_host, filename, id_storage, id_project=None,
query_parameters["keys"] = ','.join(list(properties.keys()))
query_parameters["values"] = ','.join(list(properties.values()))

m = MultipartEncoder(fields={"files[]": (filename, open(filename, 'rb'))})
response = self._session.post("{}/upload".format(upload_host),
basename = os.path.basename(filename)
m = MultipartEncoder(fields={"files[]": (basename, open(filename, 'rb'))})
response = self._session.post(f"{upload_host}/upload",
auth=CytomineAuth(
self._public_key, self._private_key,
upload_host, ""),
Expand Down

0 comments on commit ce65e6a

Please sign in to comment.