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

Automatically set content-type based on file type #1184

Closed
atn opened this issue May 11, 2020 · 6 comments · Fixed by #1190
Closed

Automatically set content-type based on file type #1184

atn opened this issue May 11, 2020 · 6 comments · Fixed by #1190
Assignees
Labels
api: storage Issues related to the googleapis/nodejs-storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@atn
Copy link
Contributor

atn commented May 11, 2020

While uploading a file to a Storage Bucket, the API automatically sets the content-type to application/octet-stream instead of setting it to what it should be. e.g. image/png etc.

Describe the solution you'd like
Instead of having to manually set this metadata or it being set to application/octet-stream, let the API automatically set this based on the file extension.
Describe alternatives you've considered
Check for each file type extension and then set the metadata manually.

@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label May 11, 2020
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label May 12, 2020
@stephenplusplus
Copy link
Contributor

stephenplusplus commented May 12, 2020

We do this if you put contentType: 'auto'!:

* @property {string} [contentType] Alias for
.

We didn't set that by default at the time to avoid making a breaking change (#133 (comment)). But, maybe we should now, @JustinBeckwith?

@stephenplusplus stephenplusplus added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed triage me I really want to be triaged. labels May 12, 2020
@JustinBeckwith
Copy link
Contributor

I think that's a good idea. @frankyn and @jkwlui to make the final call though.

@atn
Copy link
Contributor Author

atn commented May 12, 2020

Thanks guys. Great job on this library as-well.

@jkwlui
Copy link
Member

jkwlui commented May 12, 2020

+1. We already do this in the go library. We can ship it along with the 5.0.0 release.

@stephenplusplus
Copy link
Contributor

Woo! @austtn any interest in sending a PR to make the change? We would want to just set the flag to "auto" if the user doesn't specify their own value for options.contentType. Aside from that, just one new test in test/file.ts to confirm we set it to default?

No worries if not :)

@atn
Copy link
Contributor Author

atn commented May 13, 2020

I think this issue can be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants