PHP code example of nassiry / filesize-handler-googlecloud-extension
1. Go to this page and download the library: Download nassiry/filesize-handler-googlecloud-extension 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/ */
nassiry / filesize-handler-googlecloud-extension example snippets
use Nassiry\FileSizeUtility\FileSizeHandler;
use Nassiry\FileSizeUtility\Extensions\GoogleCloudFiles;
use Google\Cloud\Storage\StorageClient;
$gcsClient = new StorageClient([
'keyFilePath' => '/path/to/keyfile.json',
]);
$handler = FileSizeHandler::create()
->from(new GoogleCloudFiles(
$gcsClient, // Google Cloud Storage Client
'my-bucket', // Google Cloud bucket name
'path/to/file.txt' // File path in the bucket
))
->formattedSize();
echo $handler; // Output: "15.67 MiB"