简体   繁体   English

在Rails中使用回形针时获取全局s3存储桶名称

[英]getting global s3 bucket name while using paperclip in rails

This is probably a silly question, but is there a way I can pull out the root bucket name out of the YML s3 file I have? 这可能是一个愚蠢的问题,但是有什么办法可以从我拥有的YML s3文件中拉出根存储桶名称? Other tutorials I've seen just assume that the buckets are named development/test-(whatever). 我见过的其他教程只是假设这些存储桶被命名为development / test-(无论如何)。 I just want to pull exactly what is in the amazon 3s yml out of there, or else I'll have to hard code it... 我只想确切地提取亚马逊3s yml中的内容,否则我将不得不对其进行硬编码。

I've tried like S3_CONFIG['bucket_name'] but I think that may be attachment_fu specific, not sure. 我已经尝试过像S3_CONFIG ['bucket_name']一样,但是我认为可能是附件_fu特有的,不确定。

Remember, you can always parse the YAML file yourself. 请记住,您始终可以自己解析YAML文件。

Probably something along these lines: 可能遵循以下原则:

config = YAML.load_file(Rails.root.join('config', 'aws_s3.yml'))
bucket_name = config[Rails.env]['bucket_name']

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM