tmzkj-yii2-shop/yii2-shop-storage 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tmzkj-yii2-shop/yii2-shop-storage

Composer 安装命令:

composer require tmzkj-yii2-shop/yii2-shop-storage

包简介

A file uploading extension for Yii2, saving files to object storage service.

README 文档

README

Thanks for your attention. This package is only used for my company projects, please do NOT use it in your product environment.

Usage

  1. Firstly, add this lines of code to your Yii application config:

    'components' => [
        'class' => 'Tmzkj\Storage\Components\StorageComponent',
        'basePath' => 'temp/',
        'driver' => [
            'class' => 'Tmzkj\Storage\Drivers\Local',
            'accessKey' => '',
            'secretKey' => '',
            'bucket' => '',
        ]
    ]
  2. Then after app bootstarpping, you would get the storage component instance like that:

    $storage = \Yii::$app->storage;

    Alternatively, you can also create a driver while app running:

    $storage->setDriver('Tmzkj\Storage\Drivers\Local', []);
  3. Fetch uploaded file by field name:

    $file = $storage->getUploadedFile('FILE-FIELD-NAME');
  4. Save it.

    $url = $file->saveAs('NEW-FILE-NAME.EXT');
    // or
    $url = $file->saveWithOriginalExtension('NEW-FILE-BASE-NAME');
    // or
    $url = $file->saveAsUniqueHash();

    $url will be a URL string which can access this file on success, or false on failure.

    If there's any error occurred, these methods will throw a Tmzkj\Storage\Exceptions\StorageException. Don't forget to try... catch ....

About

Working at: Zhejiang Tmzkj Technology Co., Ltd.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-12-01