Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

阿里云存储OSS在这里如何配置 #7

Open
lidenggao opened this issue Mar 6, 2016 · 3 comments
Open

阿里云存储OSS在这里如何配置 #7

lidenggao opened this issue Mar 6, 2016 · 3 comments

Comments

@lidenggao
Copy link

如题,我上传的资源都要放到OSS中,访问路径也是,请问能不能自定义上传的处理功能?

@ihipop
Copy link

ihipop commented Mar 26, 2016

这个应该通过wrappers来实现比较好 你自己通过stream_wrapper_register注册一个 oss:// 的wrap ,把文件存储的逻辑封在里面然后把编辑器配置的根路径直接指向这个地址就行

http://php.net/manual/zh/wrappers.php

http://php.net/manual/zh/function.stream-wrapper-register.php

@ijackwu
Copy link

ijackwu commented Jan 19, 2017

这个可以 'kucha\ueditor\UEditorAction', 定义一个类集成重写uploads就好了

@xiongjinchao
Copy link

我直接继承了原来的Action

<?php
namespace backend\components;

use Yii;
use kucha\ueditor\UEditorAction as UEditor;
use common\components\AliyunOss;
use yii\helpers\ArrayHelper;

class UEditorAction extends UEditor
{
    public function init()
    {
        parent::init();
    }

    public function run()
    {
        $data = parent::run();

        // 上传到 OSS
        if(ArrayHelper::getValue($data,'state') == 'SUCCESS' && Yii::$app->params['upload']['type'] == 'oss'){
            $aliyunOSS = new AliyunOss();
            if($aliyunOSS->uploadFile(substr($data['url'],1), Yii::$app->params['upload']['config']['local']['dir'].$data['url'])){
                @unlink(Yii::$app->params['upload']['config']['local']['dir'].$data['url']);
            }else{
                $data['state'] = 'FAILURE';
            }
        }

        return $data;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants