boto3 icon indicating copy to clipboard operation
boto3 copied to clipboard

Set ContentType header based on file extension when possible

Open ghost opened this issue 7 years ago • 11 comments

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.

ghost avatar May 19 '17 01:05 ghost

Thanks for the contribution! Taking a look.

JordonPhillips avatar May 25 '17 20:05 JordonPhillips

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.

dstufft avatar May 25 '17 20:05 dstufft

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. :) .

ghost avatar May 26 '17 17:05 ghost

I'll work on an updated PR as you describe and have it ready soon.

ghost avatar May 26 '17 17:05 ghost

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.

robin-norwood avatar May 27 '17 21:05 robin-norwood

What's the status with this? The pull request would be a really useful feature

epicfaace avatar Apr 21 '18 03:04 epicfaace

would be nice

jose-gomez-ml avatar May 14 '18 17:05 jose-gomez-ml

Anything I can do to help get this merged?

robin-norwood avatar Jul 15 '18 14:07 robin-norwood

Would really help..

PhilippeTrounev avatar Jul 23 '19 00:07 PhilippeTrounev

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?

ddeibert avatar Oct 04 '21 18:10 ddeibert

By when this feature will be available on the release?

Rizwan-Hasan avatar Apr 10 '22 15:04 Rizwan-Hasan

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.

tim-finnigan avatar Apr 27 '23 16:04 tim-finnigan