Add response-header overrides to BucketObject.generate_url#339
Merged
Conversation
generate_url gains optional content_disposition/content_type parameters that ask the backing store to serve the object with those response headers on GET — needed by consumers (e.g. Galaxy) that hand out presigned download URLs with a forced filename and MIME type. The signature is uniform across all four providers: - AWS: ResponseContentDisposition/ResponseContentType presigned params - Azure: content_disposition/content_type on the blob SAS - GCP: response-content-disposition/response-content-type signed query parameters - OpenStack Swift: the filename portion of the disposition is honored via the tempurl filename/inline query parameters (appended after signing — the tempurl signature covers only method, path and expiry); the content type cannot be overridden Both parameters are ignored for writable URLs.
8254883 to
56b82d8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BucketObject.generate_urlgains optionalcontent_disposition/content_typeparameters that ask the backing store to serve the object with those response headers on GET. Downstream consumers (e.g. Galaxy's object store) hand out presigned download URLs and need to force a filename and MIME type on the response.The signature is uniform across the interface and all four providers; each provider honors the hint where its backend supports response-header overrides:
ResponseContentDisposition/ResponseContentTypepresigned paramscontent_disposition/content_typeon the blob SAS (rscd/rsct)response-content-disposition/response-content-typesigned query paramsfilename/inlinequery params, appended after signing (the tempurl signature covers only method, path and expiry)Both parameters are ignored for writable URLs (response-serving hints only make sense for reads).
Tests
test_generate_url_with_response_headers: asserts the overrides appear in the presigned query string under the mock provider (signing is client-side, so no network needed), and against live providers fetches the URL and asserts the servedContent-Disposition/Content-Typeheaders (with the documented OpenStack content-type exemption).test_generate_url_writable_ignores_response_headers: writable URLs carry none of the override markers on any provider.Verification
tox -e py3.13-mock: full suite green (94+ tests)tox -e mypy: clean — the strict interface bar itself enforces that every provider conforms to the new signaturetox -e lint: cleanLive provider envs (
py3.13-{aws,azure,gcp,openstack}) should run via thesafe-to-testlabel flow to exercise the header assertions against real backends.