You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Remove the file with named saved on the image attribute
393
+
// Continuing the example, here "//my_bucket/images/my_image.png" will be deleted from S3
394
+
$model->removeFile('image');
395
+
```
396
+
397
+
#### Overriding Trait Methods
398
+
399
+
##### getS3Component
400
+
401
+
The S3MediaTrait depends on this component to be configured. The default configuration is to use this component on index `'s3'`, but you may use another value. For this cases, override the `getS3Component()` method:
402
+
403
+
```php
404
+
public function getS3Component()
405
+
{
406
+
return Yii::$app->get('my_s3_component');
407
+
}
408
+
```
409
+
410
+
##### attributePaths
411
+
412
+
The main method to override is `attributePaths()`, which defines a path in S3 for each attribute of yout model. Allowing you to save each attribute in a different S3 folder.
413
+
414
+
Here an example:
415
+
416
+
```php
417
+
protected function attributePaths()
418
+
{
419
+
return [
420
+
'logo' => 'logos/',
421
+
'badge' => 'images/badges/'
422
+
];
423
+
}
424
+
425
+
// or use another attribute, example: id
426
+
// ! Note: id must contain a value first if you don't want it to be empty
0 commit comments