Error
The current implementation is using the blob name to compute the key:
self.key = "{}/{}".format(s3_info["baseKey"].rstrip("/"), self.blob.name)
This will break when the file name contains disallowed characters like parenthesis.
Here is a code that should work (see the file name used):
# file: test-s3.py from nuxeo.client import Nuxeo from nuxeo.models import FileBlob host = "SERVER" auth = ("USER", "PWD") server = Nuxeo(host=host, auth=auth) batch = server.uploads.batch(handler="s3") blob = FileBlob(".../fah-installer_7.6.13_x86_64 (1).mpkg.zip") batch.upload(blob) batch.complete()
The script will fail at the batch.complete() call:
Traceback (most recent call last): File "nuxeo/client.py", line 282, in request resp.raise_for_status() File ".../requests/models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: for url: SERVER/nuxeo/api/v1/upload/batchId-9008aa8c-1af8-4d15-a67d-cb6830bbd341/0/complete During handling of the above exception, another exception occurred: Traceback (most recent call last): File "test-s3.py", line 12, in <module> batch.complete() File "nuxeo/models.py", line 230, in complete return self.service.complete(self, **kwargs) File "nuxeo/uploads.py", line 305, in complete return self.client.request("POST", endpoint, data=params, **kwargs) File "nuxeo/client.py", line 285, in request raise self._handle_error(exc) nuxeo.exceptions.HTTPError: HTTPError(400), error: 'java.lang.IllegalArgumentException: Invalid key: fah-installer_7.6.13_x86_64 (1).mpkg.zip', server trace: None
Fix
Instead of using the blob name, a UID should be used (as it is done in Web UI):
from uuid import uuid4 self.key = "{}/{}".format(s3_info["baseKey"].rstrip("/"), uuid4())
- is required by
-
NXDRIVE-2278 Fix S3 direct upload key computation
- Resolved
- Is referenced in