PHP code example of sausin / laravel-ovh

1. Go to this page and download the library: Download sausin/laravel-ovh 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/ */

    

sausin / laravel-ovh example snippets


Sausin\LaravelOvh\OVHServiceProvider::class

'ovh' => [
    'driver' => 'ovh',
    'authUrl' => env('OS_AUTH_URL', 'https://auth.cloud.ovh.net/v3/'),
    'projectId' => env('OS_PROJECT_ID'),
    'region' => env('OS_REGION_NAME'),
    'userDomain' => env('OS_USER_DOMAIN_NAME', 'Default'),
    'username' => env('OS_USERNAME'),
    'password' => env('OS_PASSWORD'),
    'containerName' => env('OS_CONTAINER_NAME'),

    // Since v1.2
    // Optional variable and only if you are using temporary signed urls.
    // You can also set a new key using the command 'php artisan ovh:set-temp-url-key'.
    'tempUrlKey' => env('OS_TEMP_URL_KEY'),

    // Since v2.1
    // Optional variable and only if you have setup a custom endpoint.
    'endpoint' => env('OS_CUSTOM_ENDPOINT'),

    // Optional variables for handling large objects.
    // Defaults below are 300MB threshold & 100MB segments.
    'swiftLargeObjectThreshold' => env('OS_LARGE_OBJECT_THRESHOLD', 300 * 1024 * 1024),
    'swiftSegmentSize' => env('OS_SEGMENT_SIZE', 100 * 1024 * 1024),
    'swiftSegmentContainer' => env('OS_SEGMENT_CONTAINER', null),

    // Optional variable and only if you would like to DELETE all uploaded object by DEFAULT.
    // This allows you to set an 'expiration' time for every new uploaded object to
    // your container. This will not affect objects already in your container.
    //
    // If you're not willing to DELETE uploaded objects by DEFAULT, leave it empty.
    // Really, if you don't know what you're doing, you should leave this empty as well.
    'deleteAfter' => env('OS_DEFAULT_DELETE_AFTER', null),
    
    // Optional variable to cache your storage objects in memory
    // You must 

Storage::url()
Storage::temporaryUrl()

        // Automatically expire after 1 hour of being uploaded.
        Storage::disk('ovh')->put('path/to/file.jpg', $contents, ['deleteAfter' => 60*60]);
        

        // Automatically delete at the beginning of next month.
        Storage::disk('ovh')->put('path/to/file.jpg', $contents, ['deleteAt' => now()->addMonth()->startOfMonth()])
        

Storage::disk('ovh')->getAdapter()->getFormPostSignature($path, $expiresAt, $redirect, $maxFileCount, $maxFileSize);

$url = Storage::disk('ovh')->getAdapter()->getUrl($path);

// Generate a signature that allows an upload to the 'images' directory for the next 10 minutes.
Storage::disk('ovh')->getAdapter()->getFormPostSignature('images', now()->addMinutes(10));

// Generate a signature that redirects to a url after successful file upload to the root of the container.
Storage::disk('ovh')->getAdapter()->getFormPostSignature('', now()->addMinutes(5), route('file-uploaded'));

// Generate a signature that allows upload of 3 files until next day.
Storage::disk('ovh')->getAdapter()->getFormPostSignature('', now()->addDay(), null, 3);

// Generate a signature that allows to upload 1 file of 1GB until the next hour.
Storage::disk('ovh')->getAdapter()->getFormPostSignature('', now()->addHour(), null, 1, 1 * 1024 * 1024 * 1024);

php artisan ovh:set-cors-headers

Storage::disk('ovh')->url('/');

Config::set('filesystems.disks.ovh.prefix', 'someprefixvalue')
sh
php artisan config:cache