0

When I manually add files to Amazon S3 , it automatically identifies the file type as follows,

enter image description here

Is there any way I can use AWS SDK boto3 to identify file types? There seems to be no such interface.

I already know about python mimetypes module, but it doesn't work to my liking.

smac2020
  • 9,637
  • 4
  • 24
  • 38
  • of course you can use boto (`get_object(...)['ContentType']`) for existing objects. for new objects, you should know (or guess) the content type.... – xerx593 Oct 13 '21 at 13:16
  • for "guessing", i'd recommend: https://stackoverflow.com/q/43580/592355 – xerx593 Oct 13 '21 at 13:30

1 Answers1

1

It's about the object metadata sent along the request. When uploading an object manually, the console sets the content-type header for recognized extensions (I'm not sure where is the list).

When using the AWS SDK, you may provide the Content-Type parameter along the put_object operation

gusto2
  • 11,210
  • 2
  • 17
  • 36