[英]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的有效区域。
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.