Is it possible to use the Amazon S3 module for stage / production only? The site I'm building, is using features. So when I export my fields for the content types, I either have the option to select Local File Storage, or the S3 File System.
I thought I had a solution, where on stage / prod, I would hide the local file system wrapper, but the issue turns out, that unless I select the S3 checkbox when editing a field in the content type, it doesn't default to S3.
I could go thru and select this option for all file fields, but then on the downside, dev will be broken.
My only other option, which I haven't tried, is setting a global variable via settings, and then using a if/else logic in the features for each file field, to pre-set the upload location for that field.
Ahhh, so messy.
Anyone come up with a clever solution in the pasts? That allows me to force files to be uploaded to S3 for stage/prod and local file system when running via local or dev?
Update:
Okay, so I noticed that features has the following hook:
hook_field_default_field_bases_alter()
So, in my module, I'm using that hook, determining if the env should be serving the files via local storage, or s3. If it's s3, I then alter it from 'public' to 's3'
I went and just to be safe, re-exported all my features, and made sure that by default, it was set to public, an not s3. Now, all my env's are using the correct storage location. I'm still not sold that what I'm doing is the best solution, but it is working. Any thoughts?
$use_s3f3 = variable_get('image_save_s3f3', FALSE);
// Only on stage/uat/prod, do we want to use s3 as the file storage engine.
if ($use_s3f3 === TRUE) {
foreach($fields as $key => $item) {
if (isset($item['settings']['uri_scheme']) && $item['settings']['uri_scheme'] === 'public') {
$fields[$key]['settings']['uri_scheme'] = 's3';
}
}
}