<p>It’s possible to do this using Yii’s <a href="https://www.yiiframework.com/doc/guide/2.0/en/concept-di-container" rel="nofollow noreferrer">dependency injection container</a>.</p>
<p>See the <a href="https://craftcms.com/knowledge-base/using-local-volumes-for-development" rel="nofollow noreferrer">Using Local Volumes for Development</a> knowledge base article to learn how.</p>

CC BY-SA 4.0
2020-08-27T11:57:36.817Z
2020-08-27T11:57:36.817Z
Brandon Kelly
<p>AFAIK, you can't change the type of your volume based on your environment. But if having a separate S3 account/bucket for dev could work for you, you can configure this with a volume.php config file. Check out <a href="https://docs.craftcms.com/v3/configuration.html#overriding-volume-settings" rel="nofollow noreferrer">this section in the docs about configuration</a> for the gist on how to use it, and the section about <a href="https://github.com/craftcms/aws-s3#per-environment-configuration" rel="nofollow noreferrer">per environment configuration</a> in the readme for the AWS-S3 plugin for the specifics for that type of volume. </p>

CC BY-SA 4.0
2018-07-03T19:02:22.967Z
2018-07-03T19:02:22.967Z
André Elvan
<p>I'm currently working on a new Craft CMS website for my company. We're using Elastic Beanstalk for hosting, which means that saving assets to file on the server isn't really viable- they get overwritten by code deployments- so I'm planning to have them saved to S3.</p>

<p>However when I or other developers are working on the site locally, uploading to S3 is both unnecessary and difficult (the company handles a <em>lot</em> of sensitive data so individual access to any of our AWS services is heavily ring-fenced). It would be preferable in development to just upload images to file locally and keep them out of version control.</p>

<p>Ideally I'd like to be able to change the root asset location depending on the environment. I've done similar things in Rails and Express apps, but am very new to Craft and PHP in general and am not sure where to begin. The official AWS integration seems to assume that you want everything going into S3 all the time. Does anyone have any experience of using different upload locations for different environments?</p>

<assets><multi-environment><s3><aws>
Uploading assets to different locations based on environment
# Uploading assets to different locations based on environment

(Asked by: username_0 on 2018-07-03)

I'm currently working on a new Craft CMS website for my company. We're using Elastic Beanstalk for hosting, which means that saving assets to file on the server isn't really viable- they get overwritten by code deployments- so I'm planning to have them saved to S3.

However when I or other developers are working on the site locally, uploading to S3 is both unnecessary and difficult (the company handles a *lot* of sensitive data so individual access to any of our AWS services is heavily ring-fenced). It would be preferable in development to just upload images to file locally and keep them out of version control.

Ideally I'd like to be able to change the root asset location depending on the environment. I've done similar things in Rails and Express apps, but am very new to Craft and PHP in general and am not sure where to begin. The official AWS integration seems to assume that you want everything going into S3 all the time. Does anyone have any experience of using different upload locations for different environments?

**Tags:** assets, multi-environment, s3, aws

---

## 2 answers

### Answer by username_1 on 2020-08-27. Score: 1

It’s possible to do this using Yii’s [dependency injection container](https://www.yiiframework.com/doc/guide/2.0/en/concept-di-container).

See the [Using Local Volumes for Development](https://craftcms.com/knowledge-base/using-local-volumes-for-development) knowledge base article to learn how.


---

### Answer by username_2 on 2018-07-03. Score: 1

AFAIK, you can't change the type of your volume based on your environment. But if having a separate S3 account/bucket for dev could work for you, you can configure this with a volume.php config file. Check out [this section in the docs about configuration](https://docs.craftcms.com/v3/configuration.html#overriding-volume-settings) for the gist on how to use it, and the section about [per environment configuration](https://github.com/craftcms/aws-s3#per-environment-configuration) in the readme for the AWS-S3 plugin for the specifics for that type of volume.


---

