定制 yoelpc4/laravel-cloudinary 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

yoelpc4/laravel-cloudinary

最新稳定版本:v6.0.0

Composer 安装命令:

composer require yoelpc4/laravel-cloudinary

包简介

Laravel Cloudinary filesystem cloud driver.

README 文档

README

Packagist Downloads Tests Code Coverage Software License Contributor Covenant

Laravel Cloudinary filesystem driver.

Requirement

Laravel Version Compatibilities

Laravel Package
12.x.x 6.x
11.x.x 5.x
10.x.x 4.x
9.x.x 3.x
8.x.x 2.x
7.x.x 2.x
6.x.x 2.x

Install

Requires this package with composer via command:

composer require yoelpc4/laravel-cloudinary

Environment Variable

Register your Cloudinary account details here. Then add these lines to your .env.

FILESYSTEM_DISK=cloudinary

CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_SECURE=true

Filesystem Configuration

Register cloudinary driver configuration in config/filesystems.php at disks section as follows

'cloudinary' => [
    'driver'         => 'cloudinary',
    'api_key'        => env('CLOUDINARY_API_KEY'),
    'api_secret'     => env('CLOUDINARY_API_SECRET'),
    'cloud_name'     => env('CLOUDINARY_CLOUD_NAME'),
    'secure'         => env('CLOUDINARY_SECURE', true),
    'resource_types' => [
        'image' => [
            'png',
            'jpeg',
            'jpg',
        ],
        'video' => [
            'mp4',
            'avi',
            'mp3',
            'flac',
        ],
        'raw'   => [
            'pdf',
            'xlsx',
            'csv',
            'txt',
        ],
    ],
],

The secure option is applied when generating url from storage, when secure = true will use https otherwise secure = false will use http as protocol.

The resource_types option is applied when generating resource type & public id whenever we call storage method such as write, writeStream, url, has, etc. Registers the appropriate file extensions according to cloudinary resource type e.g: png in image, mp4 in video, xlsx in raw, for audio files registers in video. The default resource type is image, visit image upload api reference for more information.

Tips

To use pre-defined filename as public ID when uploading to cloudinary, you need to tweak some configuration in Settings -> Upload -> Upload presets as follows:

  • Click edit button on signed mode preset, initial preset is ml_default you can update it.

  • Turn on Use filename or externally defined public ID to using the pre-defined filename instead of random characters.

  • Turn off Unique filename to prevent cloudinary from adding random characters at the end of filename.

  • Click Save and you're good to go.

License

The Laravel Cloudinary is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 33
  • Watchers: 3
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-09