TL;博士
如何上傳影像并維護其原始Content Type檔案,或者生成強制我的檔案型別正確的簽名或公共 URL?
我再解釋一下:
我在 Rails 應用程式中遇到了 S3 問題(我真的在使用 
我需要將它發送到另一個服務,并使用正確的 Content-Type 獲取上傳 URL。
那么,我如何上傳影像并維護其原始影像,Content Type或者生成一個簽名或公共 URL 來強制我的檔案型別正確?
uj5u.com熱心網友回復:
您可以put_object在接受選項哈希的存盤桶實體上使用該方法,其中之一是內容型別(參考):
def upload_file(file)
object_key = "#{Time.now.to_i}-#{file.original_filename}"
@s3_bucket.put_object({
key: object_key,
body: Pathname.new(file.path),
content_type: "some/content_type"
})
end
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/421267.html
標籤:
