Skip to content

Commit 0c6d205

Browse files
committed
disposition_filename
1 parent f13a004 commit 0c6d205

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "dean_utils"
7-
version="0.0.52"
7+
version="0.0.53"
88
authors=[
99
{ name="Dean MacGregor", email="powertrading121@gmail.com"}
1010
]

src/dean_utils/utils/az_utils.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,14 @@ async def rm(
521521
expand_path=expand_path,
522522
)
523523

524-
def make_sas_link(self, filepath, expiry=None, write=False):
524+
def make_sas_link(
525+
self,
526+
filepath: str,
527+
expiry: datetime | None = None,
528+
*,
529+
write: bool = False,
530+
content_disposition_filename: str | None = None,
531+
):
525532
account_dict = {
526533
x.split("=", 1)[0]: x.split("=", 1)[1]
527534
for x in self.connection_string.split(";")
@@ -532,13 +539,20 @@ def make_sas_link(self, filepath, expiry=None, write=False):
532539
expiry = datetime(2050, 1, 1, tzinfo=timezone.utc)
533540
if isinstance(expiry, str):
534541
expiry = datetime.fromisoformat(expiry)
542+
if content_disposition_filename is None:
543+
content_disposition = None
544+
else:
545+
content_disposition = (
546+
f'attachment; filename="{content_disposition_filename}"'
547+
)
535548
sas = asb.generate_blob_sas(
536549
account_name=account_dict["AccountName"],
537550
account_key=account_dict["AccountKey"],
538551
container_name=filepath.split("/", 1)[0],
539552
blob_name=filepath.split("/", 1)[1],
540553
permission=asb.BlobSasPermissions(read=True, write=write),
541554
expiry=expiry,
555+
content_disposition=content_disposition,
542556
)
543557
return f"https://{account_dict['AccountName']}.blob.core.windows.net/{filepath}?{sas}"
544558

0 commit comments

Comments
 (0)