【问题标题】:Is there a way to examine the URL used by the paperclip gem?有没有办法检查回形针 gem 使用的 URL?
【发布时间】:2021-10-02 15:32:31
【问题描述】:

我正在使用带有 rails 4.2 和 MinIO 的 kreeti/kt-paperclip gem。我相信我已正确设置模型,但我收到“Aws::S3::Errors::InvalidAccessKeyId:您提供的 AWS 访问密钥 ID 在我们的记录中不存在。”我进行了验证路径和凭据的测试。我想知道 gem 是在使用我的本地 MinIO 服务器还是正在尝试访问 AWS。有没有办法不使用数据包嗅探器来验证它是否正在尝试使用正确的 S3 服务?

has_attached_file :attachment, path: "submission/attachments/:id/:basename.:extension",
    storage: :s3, s3_credentials: Proc.new{|a| a.instance.s3_credentials }, url: ":s3_path_url"
def s3_credentials
    {
      bucket: "bucket_name",
      access_key_id: "MYKEY",
      secret_access_key: "MYSECRET,
      s3_region: "us-west-1",
      s3_protocol: "http",
      s3_host_name: "play.minio.io:9000"
    }
  end

【问题讨论】:

    标签: ruby ruby-on-rails-4 paperclip minio


    【解决方案1】:

    我在 MinIO 文档网站上偶然发现了答案。 https://docs.min.io/docs/how-to-use-paperclip-with-minio-server.html

    首先,我将选项放入凭据中,这是不对的。此外还有其他选项。

      has_attached_file :attachment,
                        storage: :s3,
                        s3_protocol: ':http',
                        s3_permissions: 'public',
                        s3_region: 'us-west-1',
                        s3_credentials: {
                          bucket: 'bucket_name',
                          access_key_id: 'MYKEY',
                          secret_access_key: 'MYSECRET',
                        },
                        s3_host_name: 'play.minio.io:9000',
                        s3_options: {
                          endpoint: "http://play.minio.io:9000",
                          force_path_style: true
                        },
                        url: ":s3_path_url",
                        path: "submission/attachments/:id/:basename.:extension"
    

    【讨论】:

      猜你喜欢
      • 2016-04-04
      • 2011-12-01
      • 1970-01-01
      • 2020-09-18
      • 2019-05-06
      • 2016-01-09
      • 2010-12-20
      • 1970-01-01
      • 2016-05-27
      相关资源
      最近更新 更多