Skip to content

Commit 0bd9212

Browse files
committed
Change a saving of a local mediafile url and getting a local public file link. Doc upgrade
1 parent a435543 commit 0bd9212

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Addition module description you can see in my [Personal site](https://pack-devel
3131

3232
- php >= 7.1
3333
- composer
34-
- MySql >= 5.5
3534

3635
3 Installation
3736
----------------------------
@@ -40,12 +39,12 @@ Addition module description you can see in my [Personal site](https://pack-devel
4039

4140
Via composer:
4241

43-
```composer require itstructure/yii2-multi-format-uploader ^2.1.4```
42+
```composer require itstructure/yii2-multi-format-uploader ~2.2.0```
4443

4544
or in section **require** of composer.json file set the following:
4645
```
4746
"require": {
48-
"itstructure/yii2-multi-format-uploader": "^2.1.4"
47+
"itstructure/yii2-multi-format-uploader": "~2.2.0"
4948
}
5049
```
5150
and command ```composer install```, if you install yii2 project extensions first,
@@ -185,7 +184,8 @@ use Itstructure\MFUploader\components\{
185184
'components' => [ // CUSTOM
186185
'local-upload-component' => [ // CUSTOM
187186
'class' => LocalUploadComponent::class,
188-
'checkExtensionByMimeType' => false
187+
'checkExtensionByMimeType' => false,
188+
'uploadRoot' => dirname($_SERVER['SCRIPT_FILENAME'])
189189
],
190190
's3-upload-component' => [ // CUSTOM
191191
'class' => S3UploadComponent::class,
@@ -195,10 +195,17 @@ use Itstructure\MFUploader\components\{
195195
's3DefaultBucket' => 'bucketname',
196196
],
197197
],
198+
'publicBaseUrl' => 'http://your-site-address.com'
198199
],
199200
],
200201
```
201202

203+
Here ```publicBaseUrl``` for example can be a project domain (```http://your-site-address.com```).
204+
If we have ```url``` in ```mediafiles``` table ```\uploads\images\imagealbum\0d\3890\a947f268d6f9fd02d8a0d7e147da922c.jpg```, and we use **getViewUrl()** function from a ```mediafile``` model for local files,
205+
then for example a result link to image for ```src``` attribute of ```<img>``` tag will be:
206+
207+
```http://your-site-address.com/uploads/images/imagealbum/0d/3890/a947f268d6f9fd02d8a0d7e147da922c.jpg```
208+
202209
**Note:** It is not necessary to configure two components: ```local-upload-component``` and ```s3-upload-component```.
203210
You must configure minimum one component, according with the ```defaultStorageType```.
204211

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
### CHANGE LOG:
22

3+
**2.2.0 June 15, 2020:**
4+
- Change saving local file **url** to DB.
5+
- Add **publicBaseUrl** param to Module for full local files url.
6+
- Add **getViewUrl()** to getting file's url with a public base url just for local storage.
7+
38
**2.1.5 June 9, 2020:**
49
- Documentation upgrade. Change link to personal site.
510

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"yiisoft/yii2-bootstrap": "^2.0",
1010
"yiisoft/yii2-imagine": "~2.1.0",
1111
"aws/aws-sdk-php": "~3.55.7",
12-
"itstructure/yii2-field-widgets": "^1.2.0"
12+
"itstructure/yii2-field-widgets": "^1.2.2"
1313
},
1414
"license": "MIT",
1515
"authors": [

src/components/S3UploadComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class S3UploadComponent extends BaseUploadComponent implements UploadComponentIn
9191
*/
9292
public function init()
9393
{
94-
if (null === $this->credentials && !is_callable($this->credentials)) {
94+
if (!is_array($this->credentials) && !is_callable($this->credentials)) {
9595
throw new InvalidConfigException('Credentials are not defined correctly.');
9696
}
9797

0 commit comments

Comments
 (0)