Issue #6223
closedPulp configured with S3 doesn't include file type extension in Content-Disposition header
Description
After Pulp redirects the user to Amazon S3 to download the file the user receives it but it does not have the correct file extension. The Artifact extension is something stored in Pulp's database. It's also possible that one Artifact is present in multiple repos as various filenames so this needs to be set as a per-request piece of data.
Updated by fao89 over 4 years ago
- Triaged changed from No to Yes
- Sprint set to Sprint 67
Updated by fao89 over 4 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to fao89
Updated by fao89 over 4 years ago
I tested it out and it seems to be delivering Content-Disposition:
(pulp) [vagrant@pulp3-source-fedora30 pulp_file]$ http http://pulp3-source-fedora30.localhost.example.com/pulp/content/d25030e3-cfdd-4b48-9b15-f3c5fd7e8767/1.iso
HTTP/1.1 302 Found
Connection: keep-alive
Content-Length: 10
Content-Type: text/plain; charset=utf-8
Date: Wed, 04 Mar 2020 18:39:58 GMT
Location: http://localhost:9000/pulp3/artifact/02/77b750a47e23de8a391ca5ccfa00e8dbb19419814a229d31f1d7ba382783d2?response-content-disposition=attachment%3Bfilename%3D1.iso&X-Amz-Algorithm=A$
S4-HMAC-SHA256&X-Amz-Credential=AKIAIT2Z5TDYPX3ARJBA/20200304/eu-central-1/s3/aws4_request&X-Amz-Date=20200304T183958Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=e8eae4f9f1$1bd0288a1970e4f7a188be4f69c6d443a1a76a1e1e59b333c0d5b
Server: nginx/1.16.1
302: Found
(pulp) [vagrant@pulp3-source-fedora30 pulp_file]$ http --follow http://pulp3-source-fedora30.localhost.example.com/pulp/content/d25030e3-cfdd-4b48-9b15-f3c5fd7e8767/1.iso
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Disposition: attachment;filename=1.iso
Content-Length: 1024
Content-Security-Policy: block-all-mixed-content
Content-Type: application/octet-stream
Date: Wed, 04 Mar 2020 18:40:03 GMT
ETag: "4a0a5bb0213434a6d1201dfed4a8794a"
Last-Modified: Wed, 04 Mar 2020 18:37:27 GMT
Server: MinIO/RELEASE.2020-02-27T00-23-05Z
Vary: Origin
X-Amz-Request-Id: 15F92DE48BA99B36
X-Xss-Protection: 1; mode=block
+-----------------------------------------+
| NOTE: binary data not shown in terminal |
+-----------------------------------------+
(pulp) [vagrant@pulp3-source-fedora30 pulp_file]$ http -d http://pulp3-source-fedora30.localhost.example.com/pulp/content/d25030e3-cfdd-4b48-9b15-f3c5fd7e8767/1.iso
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Disposition: attachment;filename=1.iso
Content-Length: 1024
Content-Security-Policy: block-all-mixed-content
Content-Type: application/octet-stream
Date: Wed, 04 Mar 2020 18:40:14 GMT
ETag: "4a0a5bb0213434a6d1201dfed4a8794a"
Last-Modified: Wed, 04 Mar 2020 18:37:27 GMT
Server: MinIO/RELEASE.2020-02-27T00-23-05Z
Vary: Origin
X-Amz-Request-Id: 15F92DE7093849EA
X-Xss-Protection: 1; mode=block
Downloading 1.00 kB to "1.iso"
Done. 1.00 kB in 0.00043s (2.29 MB/s)
But from here I can see Content-Disposition is set based on relative_path: https://github.com/pulp/pulpcore/blob/master/pulpcore/content/handler.py#L558-L559
content_disposition = f'attachment;filename={content_artifact.relative_path}'
from my test, it worked with 1.iso because:
In [1]: [o.relative_path for o in ContentArtifact.objects.all()]
Out[1]: ['1.iso', '2.iso', '3.iso', 'PULP_MANIFEST']
Updated by bmbouter over 4 years ago
Maybe uploading the content instead causes it to be entered in the db differently? Does content created from this test also have the file extension in the db?
Updated by fao89 over 4 years ago
you were right, for that test:
In [1]: [o.relative_path for o in ContentArtifact.objects.all()]
Out[1]: ['pulp.nvymlldlmyekgkkdnnhrbpybwo.1.0.0']
Updated by bmbouter over 4 years ago
That is great! Can that be fixed, and also an assertion added on it being correct in the tests maybe?
Also I think it needs a database migration since the code is in production on automation hub already. Would you be willing to add a database migration also? Let me know if you want to collaborate on how to write that or test it.
Updated by fao89 over 4 years ago
- Status changed from ASSIGNED to POST
Added by Fabricio Aguiar over 4 years ago
Updated by Anonymous over 4 years ago
- Status changed from POST to MODIFIED
Applied in changeset ansible_plugin:pulp_ansible|9c32bd0279186c6134dbcb20bb1e784990f545ae.
Added by Fabricio Aguiar over 4 years ago
Revision 5ddf15d9 | View on GitHub
Fix extension migration
Updated by daviddavis over 4 years ago
- Project changed from Pulp to Ansible Plugin
Updated by bmbouter about 4 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Including file type extension
https://pulp.plan.io/issues/6223 closes #6223