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.
We do this if you put contentType: 'auto'!: https://github.com/googleapis/nodejs-storage/blob/51460e7573a7fa24bb786aded2a4bfdf262d38e6/src/file.ts#L1547.
We didn't set that by default at the time to avoid making a breaking change (https://github.com/googleapis/nodejs-storage/pull/133#issuecomment-364467599). But, maybe we should now, @JustinBeckwith?
I think that's a good idea. @frankyn and @jkwlui to make the final call though.
Thanks guys. Great job on this library as-well.
+1. We already do this in the go library. We can ship it along with the 5.0.0 release.
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 :)
I think this issue can be closed?
Most helpful comment
I think that's a good idea. @frankyn and @jkwlui to make the final call though.