PHP code example of jeddsaliba / azure-blob-url-generator
1. Go to this page and download the library: Download jeddsaliba/azure-blob-url-generator 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/ */
jeddsaliba / azure-blob-url-generator example snippets
// Add media to a model
$yourModel->addMedia($pathToFile)
->toMediaCollection('documents', 'azure');
// Get the Azure Blob SAS URL
$media = $yourModel->getFirstMedia('documents');
$url = $media->getUrl(); // Returns full URL with SAS token
// Get a temporary URL (uses same SAS token - ensure your SAS has appropriate expiration)
$temporaryUrl = $media->getTemporaryUrl(now()->addHours(1));