boto3
boto3 copied to clipboard
Set ContentType header based on file extension when possible
This is a signal boost for the request found in issue #548 in pull request form. In short, if we can guess the proper ContentType, do so. Includes doc fix, unit tests, and a trivial typo fix.
Thanks for the contribution! Taking a look.
Hey! So after taking a look at this and having a quick discussion with the rest of the boto team, we think that this would be a great feature to have, particularly since the CLI itself already does it. However, we can't change the default behavior of upload_file()
like is currently being done because that runs the risk of breaking people who are relying on the current behavior.
Would it be acceptable for you to instead of having this be on by default, have it be an option that is passed to upload_file
, which defaults to False
to automatically guess the content type? An API of something like upload_file(..., guess_content_type=False)
I think would work out really well.
Yes - I thought about doing it that way, but wanted to avoid another option. Also, I don't care about all those other people that might break, just my own use case. :) .
I'll work on an updated PR as you describe and have it ready soon.
Here you are. I did have to make one design decision - what if both guess_mime_type is True and ContentType is set? In this case, I let ContentType "win". See e.g. unit/s3/test_transfer.py line 166.
What's the status with this? The pull request would be a really useful feature
would be nice
Anything I can do to help get this merged?
Would really help..
These comments from 2017 seems to make sense: https://github.com/boto/boto3/pull/1095#issuecomment-304114418 https://github.com/boto/boto3/pull/1095#issuecomment-304478338
But this work seems to have stalled. Are there any plans to incorporate this functionality?
By when this feature will be available on the release?
Checking in after discussing this PR with the team. As mentioned in this earlier comment, the current PR couldn't be considered as it would introduce a breaking change. If anyone is still interested in this feature, please create an issue for further discussion.