错误号:: ENOENT在亚马逊S3(没有这样的文件或目录)亚马逊、错误、文件、目录

2023-09-12 21:27:11 作者:歌尽桃花

我这是使用Amazon S3的发布图像buckets.This工作完全正常部署到Heroku的应用程序。但是,当获取相同的图像提示错误:

 变量Errno :: ENOENT(没有这样的文件或目录显示路径s3.amazonaws.com/bucket_name/app/public/messages/images/000/000/061/thumb/images。 JPEG?1362410115)
 

相同的路径复制和粘贴在浏览器的URL不起作用。如果我使用的水桶名称终点它的工作原理即与下面的路径

/bucket_name.s3.amazonaws.com/app/public/messages/images/000/000/061/thumb/images.jpeg?1362410115.

但我不知道如何配置的网址,我的模型。我下面Heroku的方式来配置AWS-SDK。

  https://devcenter.heroku.com/articles/paperclip-s3
 
亚马逊s3的使用方法 使用Amazon S3 –第一部分

型号has_attached_file好像我失去了一些东西here.For配置的其余部分,你可以检查上面的链接。

  has_​​attached_file:图像:风格=> {:中等=> 100×100>中,:拇指=&​​GT; 100×100>中}
 

感谢

解决方案

包括给予code在配置/初始化/ paper_clip.rb解决了我的问题。

 回形针:: Attachment.default_options.merge!(
        :URL => :s3_domain_url,
        :PATH => 应用程序/公/:类/:附件/:id_partition /:款式/:文件名
    )
 

I have application which is deployed to heroku using amazon s3 posting images to buckets.This works perfectly fine. But when fetch the same image it gives error:

Errno::ENOENT (No such file or directory showing path s3.amazonaws.com/bucket_name/app/public/messages/images/000/000/061/thumb/images.jpeg?1362410115)

Same path copying and pasting in browser's url doesn't work. If I am using bucket name as end point it works ie, with following path

/bucket_name.s3.amazonaws.com/app/public/messages/images/000/000/061/thumb/images.jpeg?1362410115.

But I dont know how to configure this url in my model. I am following heroku's way to configure aws-sdk.

 https://devcenter.heroku.com/articles/paperclip-s3

Model has_attached_file seems like i am missing something here.For rest of configuration you can check above link.

has_attached_file :image, :styles => { :medium => "100x100>", :thumb => "100x100>" }

Thanks

解决方案

Including given code in config/initializers/paper_clip.rb resolved my problem.

    Paperclip::Attachment.default_options.merge!(
        :url => ':s3_domain_url',
        :path => 'app/public/:class/:attachment/:id_partition/:style/:filename'
    )