PHP code example of hedii / laravel-ovh-swift-storage

1. Go to this page and download the library: Download hedii/laravel-ovh-swift-storage library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hedii / laravel-ovh-swift-storage example snippets


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' => [],
        ],
    
    ],

];

return [

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

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

];

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());