1. Go to this page and download the library: Download fypyuhu/l5-gcs 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/ */
$disk = Storage::disk('gcs');
// Put a private file on the 'gcs' disk which is a Google Cloud Storage bucket
$disk->put('test.png', file_get_contents(storage_path('app/test.png')));
// Put a public-accessible file on the 'gcs' disk which is a Google Cloud Storage bucket
$disk->put(
'test-public.png',
file_get_contents(storage_path('app/test-public.png')),
\Illuminate\Contracts\Filesystem\Filesystem::VISIBILITY_PUBLIC
);
// Put a public-accessible file with metadata on the 'gcs' disk which is a Google Cloud Storage bucket
$disk->put(
'test.png',
file_get_contents(storage_path('app/test.png')),
[
'metadata' => [
'contentDisposition' => 'attachment; filename=file.png',
'contentType' => 'image/png',
],
'visibility' => \Illuminate\Contracts\Filesystem\Filesystem::VISIBILITY_PUBLIC
]
);
// Retrieve a file
$file = $disk->get('test.png');
// Get a temporary url for 1 hour
$disk->temporaryUrl('test.png', time() + 3600);
// Get a temporary url for 1 hour with other options
// see other option: https://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.45.1/storage/storageobject?method=signedUrl
$disk->temporaryUrl('test.pdf', time() + 3600, ['saveAsName' => 'file.png']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.