|
7 | 7 | use AzureOss\Storage\Blob\ContainerClient; |
8 | 8 | use AzureOss\Storage\Blob\Options\ListBlobsOptions; |
9 | 9 | use AzureOss\Storage\Blob\Options\UploadBlockBlobOptions; |
| 10 | +use AzureOss\Storage\Common\SAS\BlobSASPermission; |
| 11 | +use AzureOss\Storage\Common\SAS\BlobSASSignatureValues; |
| 12 | +use AzureOss\Storage\Common\SAS\SasIpRange; |
| 13 | +use AzureOss\Storage\Common\SAS\SasProtocol; |
| 14 | +use AzureOss\Storage\Common\SAS\SharedAccessSignatureHelper; |
10 | 15 | use DateTimeInterface; |
11 | 16 | use League\Flysystem\CalculateChecksumFromStream; |
12 | 17 | use League\Flysystem\ChecksumProvider; |
@@ -264,11 +269,42 @@ public function checksum(string $path, Config $config): string |
264 | 269 |
|
265 | 270 | public function publicUrl(string $path, Config $config): string |
266 | 271 | { |
267 | | - return "TODO"; |
| 272 | + $url = $this->containerClient->getBlobClient($path)->getUrl(); |
| 273 | + |
| 274 | + $sasValues = new BlobSASSignatureValues( |
| 275 | + $path, |
| 276 | + $config->get("cache_control"), |
| 277 | + $config->get("container_name"), |
| 278 | + $config->get("content_disposition"), |
| 279 | + $config->get("content_encoding"), |
| 280 | + $config->get("content_language"), |
| 281 | + $config->get("content_type"), |
| 282 | + $config->get("correlation_id"), |
| 283 | + $config->get("encryption_scope"), |
| 284 | + $config->get("expires_on"), |
| 285 | + $config->get("identifier"), |
| 286 | + $config->get("ip_range"), |
| 287 | + [BlobSASPermission::READ], |
| 288 | + $config->get("preauthorized_agent_object_id"), |
| 289 | + $config->get("protocol"), |
| 290 | + $config->get("snapshot_time"), |
| 291 | + $config->get("starts_on"), |
| 292 | + $config->get("version"), |
| 293 | + $config->get("version_id"), |
| 294 | + ); |
| 295 | + |
| 296 | + $sas = SharedAccessSignatureHelper::generateBlobSASQueryParameters( |
| 297 | + $sasValues, |
| 298 | + $this->containerClient->sharedKeyCredentials, |
| 299 | + ); |
| 300 | + |
| 301 | + return sprintf("%s?%s", $url, $sas); |
268 | 302 | } |
269 | 303 |
|
270 | 304 | public function temporaryUrl(string $path, DateTimeInterface $expiresAt, Config $config): string |
271 | 305 | { |
272 | | - return "TODO"; |
| 306 | + $config->withSetting("expires_on", $expiresAt); |
| 307 | + |
| 308 | + return $this->publicUrl($path, $config); |
273 | 309 | } |
274 | 310 | } |
0 commit comments