PHP code example of dptsi / laravel-storage

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

    

dptsi / laravel-storage example snippets


use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::upload($request->file('berkas'))

use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::upload(new File($path))

use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::delete($dokumen->file_id)

use Dptsi\FileStorage\Facade\FileStorage;

if($response->status == FileStorage::statusSuccess())

use Dptsi\FileStorage\Facade\FileStorage;

if($response->status == FileStorage::statusError())

    'aws_key'                   => env('AWS_ACCESS_KEY_ID'),
    'aws_secret'                => env('AWS_SECRET_ACCESS_KEY'),
    'aws_region'                => env('AWS_DEFAULT_REGION'),
    'aws_bucket'                => env('AWS_BUCKET'),

use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::awsUpload($request->file('berkas'), 'images')
//or
FileStorage::awsUpload($request->file('berkas'), 'assets/images')


use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::awsGetTemporaryPublicLink('fileid.pdf', Carbon::now->addMinutes(5))


use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::awsGetFileById('aws_file_id');


    'gcs_key_path'              => env('GOOGLE_KEY_PATH'),
    'gcs_project_id'            => env('GOOGLE_PROJECT_ID'),
    'gcs_bucket'                => env('GOOGLE_BUCKET'),

use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::gcsUpload($request->file('berkas'), 'images')
//or
FileStorage::gcsUpload($request->file('berkas'), 'assets/images')

use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::gcsDelete('gcs_file_id')

use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::gcsGetFileById('gcs_file_id')

use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::gcsDownloadFile('gcs_file_id', storage_path('temp/image.png'))

{# ▼
  +"status": "OK"
  +"string_data": bynary_string_data
}

use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::gcsGetFileByIdAsString('gcs_file_id')

{# ▼
  +"status": "OK"
  +"stream_data": GuzzleHttp\Psr7\Stream
}

use Dptsi\FileStorage\Facade\FileStorage;

FileStorage::gcsGetFileByIdAsStream('gcs_file_id')

{# ▼
  +"status": "OK"
  +"expired_at": "xxxxxxxxxxxxx"
  +"url": "xxxxxxxxxxxxx"
}