Skip to content

Commit 0206e1d

Browse files
author
brecht.vermeersch
committed
add urls
1 parent 70e629d commit 0206e1d

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

FlysystemAzureBlobStorage/AzureBlobStorageAdapter.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
use AzureOss\Storage\Blob\ContainerClient;
88
use AzureOss\Storage\Blob\Options\ListBlobsOptions;
99
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;
1015
use DateTimeInterface;
1116
use League\Flysystem\CalculateChecksumFromStream;
1217
use League\Flysystem\ChecksumProvider;
@@ -264,11 +269,42 @@ public function checksum(string $path, Config $config): string
264269

265270
public function publicUrl(string $path, Config $config): string
266271
{
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);
268302
}
269303

270304
public function temporaryUrl(string $path, DateTimeInterface $expiresAt, Config $config): string
271305
{
272-
return "TODO";
306+
$config->withSetting("expires_on", $expiresAt);
307+
308+
return $this->publicUrl($path, $config);
273309
}
274310
}

0 commit comments

Comments
 (0)