From cd8a5b9394fe679772f6cadf00071f1bed94206f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sartori?= Date: Mon, 13 Nov 2023 11:16:32 +0100 Subject: [PATCH] Add x-meta-filename to the s3 upload request --- README.md | 4 ++-- cs_upload.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 25e1400..c34dd00 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,10 @@ python cs_upload.py --trace-file foo.cst.gz ... - `--trace-file` (required): trace file to upload - `--trace-name` (optional): name of the trace created. Defaults to the file name. -- `--project-number` (required): the number of the project to upload to. You can find this +- `--project-id` (required): the number of the project to upload to. You can find this in the web UI if you navigate to that project and then look in the URL, for example in `https://[]/project/1022/dashboard`, the trace number is 1022. -- `--profile-number` (optional): the number of the profile you want to use for generating a +- `--profile-id` (optional): the number of the profile you want to use for generating a report. If this is not present, no report will be generated. To find the profile number you want, navigate to `/organization/profiles` and then select an appropriate profile. In `/organization/profiles/211` or `/organization/profiles/211/detail`, the profile diff --git a/cs_upload.py b/cs_upload.py index b4f698f..3cce35f 100644 --- a/cs_upload.py +++ b/cs_upload.py @@ -380,10 +380,9 @@ def upload_to_s3(self, form_data: str, trace_file: str) -> None: fields = json.loads(form_data) if "success_action_status" in fields: fields["success_action_status"] = str(fields["success_action_status"]) - if "x-amz-meta-filename" in fields: - fields["x-amz-meta-filename"] = os.path.basename(trace_file) mime_type = self.mime_type(trace_file) + filename = os.path.basename(trace_file) query = ["curl"] if self.ca_cert and not self.no_check_certificate: query += ["--cacert", self.ca_cert] @@ -397,6 +396,8 @@ def upload_to_s3(self, form_data: str, trace_file: str) -> None: "--form", f"Content-Type={mime_type}", "--form", + f"x-amz-meta-filename={filename}", + "--form", f"file=@{trace_file}", self.object_storage_url, ]