View more context


Files: Requires logging in with Slack to view/download
Stefan Gruncharov

Hello guys, I have a question, I’m using aws s3 bucket where all the assets are stored. The problem is by default they are uploaded in protected folder and I need them public. Is there a command that can do that for me or I have to do it manually, reason I’m asking is because they are thousands.


@Stefan Gruncharov could be that it has nothing to do with s3. In SilverStripe4 you have to publish files to see them in public. Same like pages. So - yes - you can publish them programmatically.


@Stefan Gruncharov See and

Show 1 attachment(s)
Silverstripe Forum  

Going back to your original example, have you tried just looping over the many_many relation and publishing? So on your Page you would have something like: private static $many_many = [ 'Photos' => Image::class ]; public function onAfterWrite() { parent::onAfterWrite(); foreach ($this->Photos() as $photo) { if (!$photo->isPublished()) { $photo->publishSingle(); } } }

Hide attachment content

I have this line in a template: <% loop $Images.Sort('SortOrder','ASC') %>