如何解决Ruby on Rails中Rails回形针无法显示Amazon S3上传的图片问题?

更新于
2026-10-09 19:21:40
1阅读来源:SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计264个文字,预计阅读时间需要2分钟。

如何解决Ruby on Rails中Rails回形针无法显示Amazon S3上传的图片问题?

我打算将图像上传到Amazon S3,但它没有显示。我收到错误信息:ErrorCodePermanentRedirect/CodeMessageThe bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

我将图像上传到Amazon S3,但它们没有显示.

如何解决Ruby on Rails中Rails回形针无法显示Amazon S3上传的图片问题?

我收到此错误:

<Error> <Code>PermanentRedirect</Code> <Message> The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. </Message> <Bucket>cb123</Bucket> <Endpoint>cb123.s3.amazonaws.com</Endpoint> <RequestId>870BC2E8570EF4E7</RequestId> <HostId> yuBkeXxftr7O9Ib0SasFTq8Hlvgc7hkhx9VMr+VwRL74qSDgJ9rqMgEU9noRIQe/ </HostId> </Error>

这是我的设置:

has_attached_file :image, styles: { medium: "400x400#", small: "250x250#", :url =>':s3_domain_url', :path => '/:class/:attachment/:id_partition/:style/:filename' }

谢谢!

将其添加到application.rb或每个环境的配置文件中:

config.paperclip_defaults = { :storage => :s3, :s3_host_name => 's3-eu-central-1.amazonaws.com', :s3_credentials => { :bucket => 'your bucket', :access_key_id => 'your access-key-id', :secret_access_key => 'your secret-access-key' }, :url =>':s3_domain_url', :path => '/:class/:attachment/:id_partition/:style/:filename' }

然后,您可以从模型中删除:url和:path config.

本文共计264个文字,预计阅读时间需要2分钟。

如何解决Ruby on Rails中Rails回形针无法显示Amazon S3上传的图片问题?

我打算将图像上传到Amazon S3,但它没有显示。我收到错误信息:ErrorCodePermanentRedirect/CodeMessageThe bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

我将图像上传到Amazon S3,但它们没有显示.

如何解决Ruby on Rails中Rails回形针无法显示Amazon S3上传的图片问题?

我收到此错误:

<Error> <Code>PermanentRedirect</Code> <Message> The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. </Message> <Bucket>cb123</Bucket> <Endpoint>cb123.s3.amazonaws.com</Endpoint> <RequestId>870BC2E8570EF4E7</RequestId> <HostId> yuBkeXxftr7O9Ib0SasFTq8Hlvgc7hkhx9VMr+VwRL74qSDgJ9rqMgEU9noRIQe/ </HostId> </Error>

这是我的设置:

has_attached_file :image, styles: { medium: "400x400#", small: "250x250#", :url =>':s3_domain_url', :path => '/:class/:attachment/:id_partition/:style/:filename' }

谢谢!

将其添加到application.rb或每个环境的配置文件中:

config.paperclip_defaults = { :storage => :s3, :s3_host_name => 's3-eu-central-1.amazonaws.com', :s3_credentials => { :bucket => 'your bucket', :access_key_id => 'your access-key-id', :secret_access_key => 'your secret-access-key' }, :url =>':s3_domain_url', :path => '/:class/:attachment/:id_partition/:style/:filename' }

然后,您可以从模型中删除:url和:path config.