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

Upload file with custom content type? #82

Open
shkim opened this issue Feb 9, 2022 · 1 comment
Open

Upload file with custom content type? #82

shkim opened this issue Feb 9, 2022 · 1 comment

Comments

@shkim
Copy link

shkim commented Feb 9, 2022

How can I set the content type of the uploading file? (for example, image/jpeg)
I tried to set the .ContentType member of returned value from obj.Attrs()
but it seems that Attrs() is only usable for download of existing file.
I found that there is UploadFile method but I could not find how to use.

@R167
Copy link

R167 commented Feb 12, 2022

It looks like you want the WithAttrsOption

I believe you'd need to do:

import "github.com/kurin/blazer/b2"

// ... all your setup code

w := bucket.Object(dst).NewWriter(ctx, b2.WithAttrsOption(&b2.Attrs{ContentType: "image/jpeg"}))

w.Write(myFileBlob)

see https://pkg.go.dev/github.com/kurin/blazer/b2#Attrs for the fields which can be set on upload in this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants