View more context

 

Steffan
Files: Requires logging in with Slack to view/download
image.png
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.

wmk

@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.

wmk

@Stefan Gruncharov See https://docs.silverstripe.org/en/4/developer_guides/files/file_management/#file-versioning and https://forum.silverstripe.org/t/publish/447/7?u=wmk

Show 1 attachment(s)
Silverstripe Forum  
Publish

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
Mo

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