2017 © Pedro Peláez
 

yii2-extension yii2-upload

The Qiniu 、ftp、local、aliyun-oss integration for the Yii2 framework

image

juckzhang/yii2-upload

The Qiniu 、ftp、local、aliyun-oss integration for the Yii2 framework

  • Monday, April 17, 2017
  • by juckzhang
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Qiniu Ftp AliYun Extension for Yii2

The Qiniu integration for the Yii framework, (*1)

Latest Stable Version Total Downloads License, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

composer require juckzhang/yii2-upload:*

or add, (*5)

"juckzhang/yii2-upload": "*"

to the require section of your composer.json., (*6)

Configuration

To use this extension, simply add the following code in your application configuration:, (*7)

[配置]

1、config目录下新添加上传配置文件upload.php, (*8)

return [
    'advertisement' => [
        'extensions' => null,
        'mimeTypes'  => null,
        'minSize' => 1024,
        'maxSize' => 10 * 1048576,
        'uploadRequired' => '上传文件不存在!',
        'tooBig'  => '文件大小超过限制',
        'tooSmall' => '上传文件太小',
        'tooMany' => '上传文件数量超过限制',
        'wrongExtension' => '文件扩展名不支持',
        'wrongMimeType' => '文件mime-type不支持',
        'path'  => realpath(__DIR__ . '/../upload'),
        'urlPrefix'   => 'http://localhost',
        'remoteUpload' => true,
        'recursive' => false,
    ],
];

2、, (*9)

/** QiNiu **/
return [
    'components' => [
      'uploadTool' => [
          'class' => 'juckzhang\drivers\UploadTool',
           'handler' => [
               'class' => 'juckzhang\drivers\UploadQiNiu',
               'diskName' => 'privateBucket',
               'config' => [
               'class' => 'dcb9\qiniu\Component',
               'accessKey' => 'YOUR ACCESSKEY',
               'secretKey' => 'YOUR SECRETKEY',
               'disks' => [
                   'privateBucket' => [
                       'bucket' => 'YOUR BUCKET',
                       'baseUrl' => 'http://your-domain/',
                       'isPrivate' => true,
                       'zone' => 'zone1', // 可设置为 zone0, zone1 @see \Qiniu\Zone
                   ],
               ],
           ],
      ],
    ],
]

/** OR AliYun **/
return [
    'components' => [
      'uploadTool' => [
          'class' => 'juckzhang\drivers\UploadTool',
          'handler' => [
              'class' => 'juckzhang\drivers\UploadAliYun',
              'accessKeyId' => 'YOUR ACCESSSKEYID',
              'accessKeySecret' => 'ACCESSKEYSECRET',
              'bucket' => 'test-zaizaitv-upload',
              'endPoint' => 'http://your-domain/',
          ],
      ],
    ],
]

/** OR Ftp **/
return [
    'components' => [
      'uploadTool' => [
          'class' => 'juckzhang\drivers\UploadTool',
          'handler' => [
              'class' => 'juckzhang\drivers\UploadFtp',
              'config' => [
                  'class' => 'gftp\FtpComponent',
                  'connectionString' => 'ftp://USERNAME:PASSWORD@HOST:PORT',
                  'driverOptions' => [
                      'timeout' => 30,
                  ],
              ],
          ],
      ],
    ],
  ]

[使用1]

\Yii::$app->get('uploadTool')->uploadFile($remoteFileName,$localFileName);

[使用2]

/**单文件上传**/
juckzhang\UploadService::getService()->upload($sceneType);

/**多文件上传**/
juckzhang\UploadService::getService()->multiUpload($sceneType);

[控制器中使用]

    'controllerMap' => [
        'upload' => [
            'class' => 'juckzhang\controllers\UploadController',
        ],
    ],

Tricks

The Versions

17/04 2017

dev-master

9999999-dev

The Qiniu 、ftp、local、aliyun-oss integration for the Yii2 framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Avatar juckzhang

yii2 helper qiniu ftp juckzhang aliyun-oss

17/04 2017

1.0.0

1.0.0.0

The Qiniu 、ftp、local、aliyun-oss integration for the Yii2 framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Avatar juckzhang

yii2 helper qiniu ftp juckzhang aliyun-oss