Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set cache-control header when using upload_local_file #357

Closed
djbloc opened this issue Sep 23, 2022 · 3 comments
Closed

How to set cache-control header when using upload_local_file #357

djbloc opened this issue Sep 23, 2022 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@djbloc
Copy link

djbloc commented Sep 23, 2022

How do you set the X-Bz-Info-b2-cache-control HTTP header documented here using the upload_local_file function?

I've tried to set via file_infos attribute using file_infos={"Cache-Control": "max-age=86400"} with no success.

On testing using HEAD request to S3 URL returns

HTTP/1.1 200
Accept-Ranges: bytes
Last-Modified: Fri, 23 Sep 2022 18:38:23 GMT
ETag: "079880d5addca95fa9846fa5033d72e1"
x-amz-meta-cache-control: max-age=86400
x-amz-request-id: 2a415cc03ebeade2
x-amz-id-2: aMSlmgTPFZkBlojSzNYUznDk/Ym0w2TXK
x-amz-version-id: redacted
Content-Type: video/mp2t
Content-Length: 268088
Date: Fri, 23 Sep 2022 18:40:19 GMT

On testing using HEAD request to Friendly URL returns

HTTP/1.1 200
x-bz-file-name: redacted
x-bz-file-id: redacted
x-bz-content-sha1: 4251cdc9aaa9e22c76d5191004431b84e10ed773
X-Bz-Upload-Timestamp: 1663958303158
Accept-Ranges: bytes
x-bz-info-cache-control: max-age=86400
Content-Type: video/mp2t
Content-Length: 268088
Date: Fri, 23 Sep 2022 18:41:08 GMT

Note that neither approach returns a native "Cache-Control" HTTP header

@ppolewicz
Copy link
Collaborator

As documentation of Bucket.upload_local_file shows, this is not implemented in b2-sdk-python yet. It seems that implementing it would just involve passing a parameter in a couple of places + two tests that would make sure this feature keeps working and is not broken by some future change. Would you like to take a stab at contributing a pull request to add it? b2-sdk-python developers provide quite a lot of support for contributors and you can learn quite a bit when working on it.

@ppolewicz ppolewicz added the enhancement New feature or request label Sep 24, 2022
@israel-oye
Copy link
Contributor

I have a similar problem. I want to add the {Content-Disposition: 'attachment;'} to the response header so that resources won't display inline in the browser, but I cannot for the life of me seem to find anything useful.
I might just have to use Firebase

@ppolewicz
Copy link
Collaborator

The CLI currently doesn't support setting Content-Disposition and b2-sdk-python also doesn't support it, so it'll need to be added in both places along with other missing parameters listed here.

@ppolewicz ppolewicz added help wanted Extra attention is needed good first issue Good for newcomers labels Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants