Project

Profile

Help

Issue #6223

closed

Pulp configured with S3 doesn't include file type extension in Content-Disposition header

Added by chouseknecht over 4 years ago. Updated about 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 68
Quarter:

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.

Actions #1

Updated by fao89 over 4 years ago

  • Triaged changed from No to Yes
  • Sprint set to Sprint 67
Actions #2

Updated by fao89 over 4 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to fao89
Actions #3

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']
Actions #4

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?

Actions #5

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']

Actions #6

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.

Actions #7

Updated by fao89 over 4 years ago

  • Status changed from ASSIGNED to POST
Actions #8

Updated by rchan over 4 years ago

  • Sprint changed from Sprint 67 to Sprint 68

Added by Fabricio Aguiar over 4 years ago

Revision 9c32bd02 | View on GitHub

Including file type extension

https://pulp.plan.io/issues/6223 closes #6223

Actions #9

Updated by Anonymous over 4 years ago

  • Status changed from POST to MODIFIED

Added by Fabricio Aguiar over 4 years ago

Revision 5ddf15d9 | View on GitHub

Fix extension migration

https://pulp.plan.io/issues/6223 ref #6223

Actions #10

Updated by daviddavis over 4 years ago

  • Project changed from Pulp to Ansible Plugin
Actions #11

Updated by fao89 over 4 years ago

  • Sprint/Milestone set to 0.2.0
Actions #12

Updated by bmbouter about 4 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF