blob-permission_3.py 755 B

1234567891011121314151617
  1. def create_blob_link(self, blob_folder, blob_name) -> str:
  2. if blob_folder:
  3. full_path_blob = f"{blob_folder}/{blob_name}"
  4. else:
  5. full_path_blob = blob_name
  6. url = f"https://{self.account_name}.blob.core.windows.net/{self.destination}/{full_path_blob}"
  7. sas_token = generate_blob_sas(
  8. account_name=self.account_name,
  9. account_key=self.account_key,
  10. container_name=self.destination,
  11. blob_name=full_path_blob,
  12. permission=BlobSasPermissions(read=True, delete_previous_version=False),
  13. expiry=datetime.utcnow() + timedelta(days=self.expiry_download_links),
  14. )
  15. url_with_sas = f"{url}?{sas_token}"
  16. return url_with_sas