简体   繁体   English

使用Boto上传目录时设置Content-Type键

[英]Setting Content-Type key when uploading directory using Boto

I am using os.walk to get a directory of files and then using the boto suggested way of uploading large files. 我正在使用os.walk来获取文件目录,然后使用boto建议的上传大文件的方式。 From what I have read, I need to set the content-type key at upload time, but the directory has multiple file types that need different content-type keys. 从我的阅读中,我需要在上载时设置content-type密钥,但是目录中有多种文件类型需要不同的content-type密钥。 Any suggestions on how to get the proper content-type for each file so it can be set in the key? 关于如何为每个文件获取正确的内容类型的任何建议,以便可以在密钥中进行设置? Mime types library? 哑剧类型库? Something else? 还有吗

From the documentation : 文档中

When you send data to S3 from a file or filename, boto will attempt to determine the correct mime type for that file and send it as a Content-Type header. 当您从文件或文件名向S3发送数据时,boto将尝试确定该文件的正确mime类型并将其作为Content-Type标头发送。 The boto package uses the standard mimetypes package in Python to do the mime type guessing. boto软件包使用Python中的标准mimetypes软件包进行mime类型猜测。

From the source : 来源

self.content_type = mimetypes.guess_type(self.path)[0]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM