简体   繁体   English

Amazon S3存储桶上传

[英]Amazon S3 bucket upload

How can I change my amazon s3 bucket name depending on what development area I am on. 如何根据我所在的开发区域来更改Amazon S3存储桶名称。

For example: for testing and Development I have same amazon s3 bucket. 例如:对于测试和开发,我有相同的Amazon s3存储桶。 But I want to change the bucket names dynamically depending on the environment the application will be. 但是我想根据应用程序的环境动态更改存储桶名称。

I have something like this now: 我现在有这样的事情:

$this->s3->putObjectFile($thumb_config['new_image'], 'newimage',
                                         $filename, S3::ACL_PUBLIC_READ);

I want this newimage to be dynamic depending on which server the application will be. 我希望此newimage是动态的,具体取决于应用程序将是哪个服务器。

I can make this newimage as a variable but then how I set values to this variable. 我可以将newimage设置为变量,然后再将值设置为该变量。

Please share your ideas, thoughts and experience with me. 请与我分享您的想法,想法和经验。

You could use an environment configuration file: http://ellislab.com/codeigniter/user-guide/libraries/config.html#environments 您可以使用环境配置文件: http : //ellislab.com/codeigniter/user-guide/libraries/config.html#environments

You would create this file in: 您可以在以下位置创建该文件:

./application/config/{ENVIRONMENT}/{FILENAME}.php

CodeIgniter will first try to load a configuration file from the current environment - if none is found, it will look for a global configuration file. CodeIgniter将首先尝试从当前环境中加载配置文件-如果未找到,则它将查找全局配置文件。

For example: 例如:

./application/config/production/aws.php

./application/config/development/aws.php

Locally, the development configuration will be loaded, but on a production server with the environment set to production - an alternative config can be provided. 将在本地加载开发配置,但是在环境设置为生产的生产服务器上-可以提供替代配置。

Hope this helps. 希望这可以帮助。

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

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