sateler/yii2-document 问题修复 & 功能扩展

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

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

sateler/yii2-document

Composer 安装命令:

composer require sateler/yii2-document

包简介

Yii2 model for storing documents

README 文档

README

Yii2-document stores documents in your local database or any filesystem supported by Flysystem.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist sateler/yii2-document "^1.1"

or add

"sateler/yii2-document": "^1.1"

to the require section of your composer.json file.

Once the extension is installed, add namespace to console config:

return [
    'controllerMap' => [
        'migrate' => [
            'class' => 'yii\console\controllers\MigrateController',
            'migrationNamespaces' => [
                'sateler\document\migrations',
            ],
        ],
    ],
];

And controller to web config:

return [
    'controllerMap' => [
        'documents' => [
            'class' => 'sateler\document\controllers\DocumentController',
        ]
    ],
];

Configuration

'documentManager' => [
    'class' => \sateler\document\DocumentManager::class,
    // Define default filesystem, of none given sql storage is used
    'defaultFilesystemId' => 'awsS3',
    'filesystems' => [
        // A flysystem filesystem config
        'awsS3' => [
            'class' => AwsS3Filesystem::class,
            'bucket' => 'bucket-name',
            'region' => 'us-east-1',
            'prefix' => 'path',
            'key' => 'key',
            'secret' => 'secret',
        ],
    ],
],

Usage

Once installed, you can now use sateler\document\Document in your relations, and redirect to ['documents/view', 'id' => $docId] to view or download.

Create a document and save it:

$doc = new Document();
$doc->name = 'filename';
$doc->mime_type = 'mime/type';
$doc->contents = file_get_contents('/path/to/file');
$doc->save();

Get a document and send it:

$doc = Document::findOne($id)
$res = Yii::$app->response;
$res->format = Response::FORMAT_RAW;
$res->setDownloadHeaders($doc->name, $doc->mime_type, true);
$res->data = $doc->contents;
$res->send();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-07-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固