I have saved pdf files in azure blob storage blob, I want to show these files on my website but when a file render on html its link should be deactivated means no one can use that link to download the file again. Is this possible in azure blob storage?
Azure Blob Storage Temporary File URL
There are many articles related to this all over internet. e.g.: learn.microsoft.com/en-us/azure/storage/blobs/… Have a look and ask question like where are you stuck or what problemsyou're facing etc. –
Leone
You can use the blob policy to make it:
CloudStorageAccount account = CloudStorageAccount.Parse("yourStringConnection");
CloudBlobClient serviceClient = account.CreateCloudBlobClient();
var container = serviceClient.GetContainerReference("yourContainerName");
container
.CreateIfNotExistsAsync()
.Wait();
CloudBlockBlob blob = container.GetBlockBlobReference("test/helloworld.txt");
blob.UploadTextAsync("Hello, World!").Wait();
SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy();
// define the expiration time
policy.SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(1);
// define the permission
policy.Permissions = SharedAccessBlobPermissions.Read;
// create signature
string signature = blob.GetSharedAccessSignature(policy);
// get full temporary uri
Console.WriteLine(blob.Uri + signature);
If I understand correctly, you're looking for single use links to Azure Blobs. Natively this feature is not available in Azure Storage. You would need to write code to implement something like this where you would keep track of the number of times a link has been used and in case the limit exceeds, you will not process that link.
How can i keep track the number of times a link has been used? if someone try to use my storage file link on browser tab then how it is possible to validate it? –
Teryl
Please use the below link it is very helpful to get temporary azure blob file URL with shared access signature. pedro.digitaldias.com/?p=331 –
Teryl
This provides a link that will expire after a certain time and not after certain uses. –
Quotha
My file take maximum 10 secs to load so i get the url for 30 seconds, so now my file will be access with this url about for about 3 to 5 times. –
Teryl
If you are willing to take that as an acceptable risk, then yes you can go with Shared Access Signature and provide links that will expire in a short duration. –
Quotha
For now i have no choice to get generate url for certain uses. If you found something do share it. –
Teryl
© 2022 - 2024 — McMap. All rights reserved.