承接 hedii/laravel-ovh-swift-storage 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

hedii/laravel-ovh-swift-storage

最新稳定版本:4.2.0

Composer 安装命令:

composer require hedii/laravel-ovh-swift-storage

包简介

Out of the box Ovh Swift storage usage for Laravel

README 文档

README

Build Status Total Downloads License Latest Stable Version

Laravel Ovh Swift Storage

Out of the box Ovh Swift storage usage for Laravel 6.0+

Table of contents

Installation

Install via composer

composer require hedii/laravel-ovh-swift-storage

Edit config/filesystems.php to add the new ovh-swift disk

return [

    'disks' => [
        /* ... */

        'ovh-swift' => [
            'driver' => 'ovh-swift',
            'authUrl' => env('OVH_SWIFT_OPENSTACK_AUTH_URL', 'https://auth.cloud.ovh.net/v3/'),
            'region' => env('OVH_SWIFT_OPENSTACK_REGION'),
            'projectId' => env('OVH_SWIFT_OPENSTACK_PROJECT_ID'),
            'containerName' => env('OVH_SWIFT_CONTAINER_NAME'),
            'prefix' => env('OVH_SWIFT_PREFIX'),
            'username' => env('OVH_SWIFT_OPENSTACK_USERNAME'),
            'password' => env('OVH_SWIFT_OPENSTACK_PASSWORD'),
            'visibility' => env('OVH_SWIFT_VISIBILITY', 'public'),
            'publicUrl' => env('OVH_SWIFT_PUBLIC_URL'),
            'urlKey' => env('OVH_SWIFT_URL_KEY'),
            'requestOptions' => [],
        ],
    
    ],

];

Edit .env to add the required environment variables

OVH_SWIFT_OPENSTACK_REGION=GRA
OVH_SWIFT_OPENSTACK_PROJECT_ID=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_CONTAINER_NAME=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_OPENSTACK_USERNAME=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_OPENSTACK_PASSWORD=xxxxxxxxxxxxxxxxxxx

Usage

Once you have modified the Laravel filesystem configuration and the environment variables, you can use the new Ovh Swift storage disk as any Laravel storage disk.

Private containers

By default, this package assumes you are using a public Object Storage container.

If you want to use a private container with temporary urls, you have to configure a temporary url key and set the visibility to private.

OVH_SWIFT_OPENSTACK_REGION=GRA
OVH_SWIFT_OPENSTACK_PROJECT_ID=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_CONTAINER_NAME=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_OPENSTACK_USERNAME=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_OPENSTACK_PASSWORD=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_VISIBILITY=private
OVH_SWIFT_URL_KEY=xxxxxxxxxxxxxxxxxxx

Be aware you will not be able to retrieve regular urls with a private container, only temporary urls.

Request options

If you want to use http request options like timeout, connect_timeout or any other valid option, put them in the driver configuration.

return [

    'disks' => [
        /* ... */

        'ovh-swift' => [
            /* ... */
            'requestOptions' => [
                'timeout' => 3.14,
                'connect_timeout' => 3.14,
            ],
        ],
    
    ],

];

Example

use Illuminate\Support\Facades\Storage;

Storage::disk('ovh-swift')->put('avatars/1', $fileContents);

$url = Storage::url('avatars/1');

// if using private containers:
$temporaryUrl = Storage::temporaryUrl('avatars/1', now()->addMinute());

Testing

If you want to test the package, you must create a new Openstack user and two new Ovh Object Storage containers:

  • A public container named test
  • A private container named test-private

Once it's done, copy phpunit.xml.dist to phpunit.xml and update the environment variables.

Be aware that the test suite will delete all files in the containers after each test. Do not test against a production containers!

To start test suite, run this command:

composer test

License

laravel-ovh-swift-storage is released under the MIT Licence. See the bundled LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固