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

Mirror of Gitee I1KGFY #150

Open
baijunyao opened this issue Jun 14, 2020 · 7 comments
Open

Mirror of Gitee I1KGFY #150

baijunyao opened this issue Jun 14, 2020 · 7 comments

Comments

@baijunyao
Copy link
Owner

https://gitee.com/baijunyao/laravel-bjyblog/issues/I1KGFY

@Edward1108
Copy link

水印没有生效的问题还是没有找到,我在本地环境测试是好的,正式环境不行。正式环境的gd扩展已安装,FreeType也有
正式环境:app/Support/helpers.php 33行代码执行成功;vendor/intervention/image/src/Intervention/Image/Image.php 156行代码执行成功。

@Edward1108
Copy link

已解决。问题是:需要清除浏览器缓存,刷新后就显示了

@baijunyao
Copy link
Owner Author

@Edward1108 针对第 3 个问题;上传图片到 OSS 是用于备份? 还是准备在网页中引用 OSS 的图片链接?

@Edward1108
Copy link

@baijunyao 希望项目里上传的附件都可以保存到oss中。我目前项目是使用的Thinkphp6,以下是我的配置文件,仅供参考。

.env
[FILESYSTEM]
DRIVER = aliyun_dev

config/filesystem.php

env('filesystem.driver', 'local'), // 磁盘列表 'disks' => [ 'local' => [ 'type' => 'local', 'root' => app()->getRuntimePath() . 'storage', ], 'public' => [ // 磁盘类型 'type' => 'local', // 磁盘路径 'root' => app()->getRootPath() . 'public/storage', // 磁盘路径对应的外部URL路径 'url' => '/storage', // 可见性 'visibility' => 'public', ], 'aliyun_dev' => [ 'type' => 'aliyun', 'accessId' => '', 'accessSecret' => '', 'bucket' => '', 'endpoint' => 'oss-cn-beijing.aliyuncs.com', 'url' => '',//不要斜杠结尾,此处为URL地址域名。 ], 'aliyun_prod' => [ 'type' => 'aliyun', 'accessId' => '', 'accessSecret' => '', 'bucket' => '', 'endpoint' => 'oss-cn-beijing-internal.aliyuncs.com', 'url' => '',//不要斜杠结尾,此处为URL地址域名。 ], ], ]; 这个方法是根据当前配置项自动构造文件的访问路径 /** * 域名连接 * @param $str * @return string */ public static function domainConnect($str) { if(empty($str)){ return ''; } $type = config('filesystem.disks.'.env('filesystem.driver').'.type'); $domain = config('filesystem.disks.'.env('filesystem.driver').'.url'); if(empty($domain)){ return ''; } if($type == 'local'){ $domain = app()->request->server('HTTP_HOST').$domain; } if (Str::endsWith($domain, ['/'])) { $domain = substr($domain, 0, -1); } $str = Str::startsWith($str, ['/']) ? $str : '/' . $str; return $domain . $str; }

@baijunyao
Copy link
Owner Author

baijunyao commented Jun 23, 2020

格式化上面的代码:

'disks' => [ 
    'local' => [ 
        'type' => 'local', 
        'root' => app()->getRuntimePath() . 'storage', 
    ], 
    'public' => [ // 磁盘类型 
        'type' => 'local', // 磁盘路径 
        'root' => app()->getRootPath() . 'public/storage', // 磁盘路径对应的外部URL路径 
        'url' => '/storage', // 可见性 
        'visibility' => 'public', 
    ], 
    'aliyun_dev' => [ 
        'type' => 'aliyun', 
        'accessId' => '', 
        'accessSecret' => '', 
        'bucket' => '', 
        'endpoint' => 'oss-cn-beijing.aliyuncs.com', 
        'url' => '',//不要斜杠结尾,此处为URL地址域名。 
    ], 
    'aliyun_prod' => [ 
        'type' => 'aliyun', 
        'accessId' => '', 
        'accessSecret' => '', 
        'bucket' => '', 
        'endpoint' => 'oss-cn-beijing-internal.aliyuncs.com', 
        'url' => '',//不要斜杠结尾,此处为URL地址域名。 
    ], 
], 
/** 
* 域名连接 
*
* @param $str 
* @return string 
*/ 
public static function domainConnect($str) { 
    if(empty($str)){
        return ''; 
    } 

    $type   = config('filesystem.disks.'.env('filesystem.driver').'.type'); 
    $domain = config('filesystem.disks.'.env('filesystem.driver').'.url'); 

    if(empty($domain)){ 
        return ''; 
    } 

    if($type == 'local'){ 
        $domain = app()->request->server('HTTP_HOST').$domain; 
    } 

    if (Str::endsWith($domain, ['/'])) { 
        $domain = substr($domain, 0, -1); 
    } 

    $str = Str::startsWith($str, ['/']) ? $str : '/' . $str; 

    return $domain . $str; 
}

@baijunyao
Copy link
Owner Author

baijunyao commented Jun 27, 2020

@Edward1108 功能已经开发完成 merge 到 master 了; 可以拉取最新的代码使用;
需要先配置 OSS ;
image
如果需要使用 OSS 的链接;可以在这里配置域名;
image

另外可以运行 php artisan file:sync-to-oss 命令把本地之前上传的文件同步到 OSS ;

@Edward1108
Copy link

@baijunyao 好的,谢谢。辛苦了

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

2 participants