Silverstripe S3

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

I am using silverStripe 4.4.5 and have installed the silverstripe/silverstripe-s3 module:

It’s supposed to move the assets to an S3 bucket, but everything is still going to local assets folder :frowning:

I have a bucket configured with public access, and I have entered the region, bucket name, access and secret access code in the config. Any ideas?

Thanks

If all is actually configured properly, I’d try running a ?flush to make sure the new config is picked up.

Additionally if you are adding custom config to your local instance, make sure that the yml config is set to load after the modules, eg.

---
Only:
  envvarset: AWS_BUCKET_NAME
After:
  - '#assetsflysystem'
  - '#silverstripes3-flysystem'
---
SilverStripe\Core\Injector\Injector:
  Aws\S3\S3Client:
    constructor:
      configuration:
        region: '`AWS_REGION`'
        version: latest
        credentials:
          key: '`AWS_ACCESS_KEY_ID`'
          secret: '`AWS_SECRET_ACCESS_KEY`'

Hi ,

Thanks for your reply! I think I might not have things configured properly :frowning: I’m setting AWS_BUCKET_NAME, region, api and secret in a _config.php file in my module like so:

Environment::setEnv('AWS_BUCKET_NAME', 'MY-BUCKET-NAME');

So in my controller I made a function to get the environment variable for AWS_BUCKET_NAME and write to the page, just to see if it is set, and I get nothing back. Maybe I’m doing it wrong? Or maybe the _config.php isn’t read yet? I don’t know, I’m pretty knew to SS4 but have worked for years with SS3.

Is there a different way those env variables should be set?

I think my yaml file is correct according to the example you posted.

I would not set the ENV variables in your _config.php, you will want to place those in your .env file that is in the root of your site, this should be for any site using SS4x.

Then if you need to specify your access key and secret key on your local dev environment (since not running on aws infrastructure) you can basically copy the YML config I pasted above and either add it as a new .yml file in the app/_config/ folder or add it to an existing yml config file in your project.

So I got this working, thanks to your help!

I put the ENV variables into the .env file as you suggested. But still I was running into a 500 server error on the page. So on a whim, I took the yml configuration out of app/my_module/_config/s3.yml and moved it into app/_config/mysite.yml and it started working. I have no idea why I can not configure the S3 stuff in my module. It kind of bugs but at least it is working. Thanks for your help!