简体   繁体   English

Amazon S3从Rails上传图像

[英]Amazon S3 upload Image from Rails

I'm uploading the image using aws-s3 gem, it uploads perfectly and give me the url. 我正在使用aws-s3 gem上传图像,它完美上传并提供了URL。 Image is in PNG format but when I hit the public url in my browser, it starts downloading, but I don't want to download it, I want to see the image in browser. 图片为PNG格式,但是当我在浏览器中点击公共网址时,它开始下载,但是我不想下载它,我想在浏览器中查看图片。

Please tell me if you know which parameter in the following request should be added for this or what change is required to achieve this? 请告诉我是否知道应在以下请求中的哪个参数上添加此参数,或者需要进行哪些更改才能实现?

AWS::S3::S3Object.store(base_name,open(local_file),bucket,:content_type => mime_type,:access => :public_read,:authenticated => false)

s3_url = AWS::S3::S3Object.url_for(params[:name],bucket)[/[^?]+/]

如果mime_type正确,请检查:content_type => mime_type

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

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