Skip to content

andrey-tm/yii2-aws-file-input-widget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yii2-aws-file-input-widget

Yii2 widget allows to integrate AWS S3 file upload. Based on File Input.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require andreyv/yii2-aws-file-input-widget "^1.0"

or add

"andreyv/yii2-aws-file-input-widget": "^1.0"

to the require section of your composer.json file.

Usage

Add the following to your config file

'components' => [
    ...
    'aws' => [
        'class' => andreyv\aws\fileinput\components\Aws::class,
        'credentials' => [
            'key' => 'aws-access-key',
            'secret' => 'aws-secret',
        ],
        'region' => 'aws-region',
        'bucket' => 'bucket-name',
    ],
    ...
],

Use with ActiveForm

echo $form->field($model, 'image')->widget(AwsFileInput::class, [
    'options' => ['accept' => 'image/*'], //acceptable files
]);
echo $form->field($model, 'image')->widget(AwsFileInput::class, [
    'awsComponent' => 'awsComponentName', //custom component name, `aws` by default
    'uniqueKey' => 'uniqueKey', //model unique attribute, `id` by default
    'options' => ['accept' => 'image/*'], //acceptable files
]);
echo $form->field($model, 'image')->widget(AwsFileInput::class, [
    'awsComponent' => 'awsComponentName', //custom component name, `aws` by default
    'fileNameParts' => [$model->someAttribute, 'some-key'], //custom file name parts, if not set `uniqueKey` will be used
    'options' => ['accept' => 'image/*'], //acceptable files
]);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages