简体   繁体   English

如何使用S3 API使用回形针gem在Rails应用程序上将红宝石图像上传到IBM Bluemix Object Storage?

[英]How to upload images for ruby on rails app using paperclip gem onto IBM Bluemix Object Storage using S3 API?

I have been using the tutorial: https://devcenter.heroku.com/articles/paperclip-s3 For adding images to S3 storage on AWS, but now want to use IBM's Object Storage which supports S3 API (using gem 'aws-sdk'). 我一直在使用该教程: https : //devcenter.heroku.com/articles/paperclip-s3用于将图像添加到AWS上的S3存储,但是现在想使用支持S3 API的IBM对象存储(使用gem'aws-sdk “)。

Using below: 在下面使用:

config.paperclip_defaults = {
    storage: :s3,
    s3_credentials: {
      bucket: ENV.fetch('S3_BUCKET_NAME'),
      access_key_id: ENV.fetch('ACCESS_KEY_ID'),
      secret_access_key: ENV.fetch('SECRET_ACCESS_KEY'),
      s3_region: ENV.fetch('REGION'),
    }
  }

where REGION = 'us-geo' 其中REGION = 'us-geo'

gives the error 给出错误

Seahorse::Client::NetworkingError (Failed to open TCP connection to david-provest-movies.s3.us-geo.amazonaws.com:443 (getaddrinfo: Name or service not known)).


How would I change the 'david-provest-movies.s3.us-geo.amazonaws.com:443' to the desired 'david-provest-movies.s3-api.us-geo.objectstorage.softlayer.net' URL? 如何将“ david-provest-movies.s3.us-geo.amazonaws.com:443”更改为所需的“ david-provest-movies.s3-api.us-geo.objectstorage.softlayer.net” URL?

Link to the API: https://developer.ibm.com/recipes/tutorials/cloud-object-storage-s3-api-intro/ 链接到API: https : //developer.ibm.com/recipes/tutorials/cloud-object-storage-s3-api-intro/

Thank you :) 谢谢 :)

That is not a valid region for s3. 这不是s3的有效区域。

  • us-east-2 美东2
  • us-west-1 美西1
  • us-west-2 美西2
  • ca-central-1 CA-中央-1
  • ap-south-1 AP-南1
  • ap-northeast-2 AP-东北-2
  • ap-southeast-1 AP-东南-1
  • ap-southeast-2 AP-东南-2
  • ap-northeast-1 AP-东北-1
  • eu-central-1 EU-中央-1
  • eu-west-1 欧盟 - 西1
  • eu-west-2 欧盟 - 西2
  • sa-east-1 SA-东1

http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

Here is bluemix 这是bluemix

Note: Using third-party tools or SDKs may enforce setting a 'LocationConstraint' when creating a bucket. 注意:创建存储区时,使用第三方工具或SDK可能会强制设置“ LocationConstraint”。 If required, this value must be set to 'us-standard'. 如果需要,此值必须设置为“ us-standard”。 Unlike AWS S3, IBM COS uses this value to indicate the storage class of an object. 与AWS S3不同,IBM COS使用此值指示对象的存储类。 This field has no relation to physical geography or region - those values are provided within the endpoint used to connect to the service. 此字段与自然地理或地区无关-这些值在用于连接服务的端点内提供。 Currently, the only permitted values for 'LocationCostraint' are 'us-standard', 'us-vault', 'us-cold', 'us-flex', 'us-south-standard', 'us-south-vault', us-south-cold', and 'us-south-flex'. 当前,“ LocationCostraint”的唯一允许值为“ us-standard”,“ us-vault”,“ us-cold”,“ us-flex”,“ us-south-standard”和“ us-south-vault” ,“ us-south-cold”和“ us-south-flex”。

I haven't actually tried to use paperclip yet, but the issue here is that the IBM Cloud endpoint needs to be specified. 我实际上还没有尝试使用回形针,但是这里的问题是需要指定IBM Cloud端点。 I'll take a closer look at the paperclip docs, but it looks like something along the lines of specifying the bucket URL (where {bucket-name} is hard coded in the below snippet but could be constructed) or some other method to explicitly specify the host name or root URL. 我将仔细看一下回形针文档,但是看起来就像在指定存储桶URL(在下面的代码段中{bucket-name}是硬编码但可以构造)的过程中一样指定主机名或根URL。 There's a chance that paperclip has the AWS endpoint hardcoded and the team at IBM will need to contribute a method for setting a custom endpoint ( which is fully supported in the aws-sdk gem when creating clients ). 回形针可能会对AWS端点进行硬编码,并且IBM团队需要提供一种方法来设置自定义端点( 创建客户端时, aws-sdk gem会完全支持该方法 )。

config.paperclip_defaults = {
    storage: :s3,
    s3_credentials: {
      bucket: ENV.fetch('S3_BUCKET_NAME'),
      access_key_id: ENV.fetch('ACCESS_KEY_ID'),
      secret_access_key: ENV.fetch('SECRET_ACCESS_KEY'),
      s3_region: ENV.fetch('REGION'),
      bucket_url: 'https://{bucket-name}.s3-api.us-geo.objectstorage.softlayer.net'
    }
  }

Let me know if it seems like using an explicit bucket URL doesn't work, and I'll look into whether the endpoint is hardcoded in paperclip and what we can do to fix it. 让我知道如果使用显式存储桶URL似乎不起作用,我将调查端点是否在回形针中进行了硬编码以及我们如何解决该问题。

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

相关问题 如何使用滑轨,角度和回形针将图像上传到S3 - How to upload images to S3 using rails, angular & paperclip 如何使用回形针从s3访问同一Ruby on Rails应用程序中的私人和公共图像 - How to access private and public images in the same Ruby on Rails app from s3 using paperclip 如何使用paperclip gem将图像上传到S3 - How to upload an image to S3 using paperclip gem 使用s3和Rails应用上的回形针上传两个图像 - Uploading two images using s3 and paperclip on rails app Rails:将雾(回形针)与Bluemix Object Storage v2一起使用 - Rails: Using Fog (paperclip) with Bluemix Object Storage v2 Rails4.2:使用AWS S3 / Paperclip Gem无法显示图像 - Rails4.2 : Images not showing up using Aws S3/Paperclip Gem 无法使用ruby on rails和paperclip gem上传zip文件 - Can't upload zip files using ruby on rails and paperclip gem 使用remotipart gem和Paperclip在Ruby on Rails中上传图像 - Image upload in Ruby on Rails using remotipart gem and Paperclip 无法使用Cloudinary(回形针)gem将图像上传到云-Rails - Cannot upload images to the cloud using Cloudinary(paperclip) gem - Rails 使用Activeadmin + Paperclip将Rails直接上传到Amazon S3 - Rails direct upload to Amazon S3 using Activeadmin + Paperclip
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM