File tree Expand file tree Collapse file tree 4 files changed +8
-7
lines changed
backend/chainlit/data/storage_clients Expand file tree Collapse file tree 4 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 44from azure .storage .blob import BlobSasPermissions , ContentSettings , generate_blob_sas
55from azure .storage .blob .aio import BlobServiceClient as AsyncBlobServiceClient
66
7- from chainlit .data .storage_clients .base import EXPIRY_TIME , BaseStorageClient
7+ from chainlit .data .storage_clients .base import BaseStorageClient , storage_expiry_time
88from chainlit .logger import logger
99
1010
@@ -33,7 +33,7 @@ async def get_read_url(self, object_key: str) -> str:
3333
3434 sas_permissions = BlobSasPermissions (read = True )
3535 start_time = datetime .now (tz = timezone .utc )
36- expiry_time = start_time + timedelta (seconds = EXPIRY_TIME )
36+ expiry_time = start_time + timedelta (seconds = storage_expiry_time )
3737
3838 sas_token = generate_blob_sas (
3939 account_name = self .storage_account ,
Original file line number Diff line number Diff line change 1+ import os
12from abc import ABC , abstractmethod
23from typing import Any , Dict , Union
34
4- EXPIRY_TIME = 3600
5+ storage_expiry_time = int ( os . getenv ( "STORAGE_EXPIRY_TIME" , 3600 ))
56
67
78class BaseStorageClient (ABC ):
Original file line number Diff line number Diff line change 44from google .oauth2 import service_account
55
66from chainlit import make_async
7- from chainlit .data .storage_clients .base import EXPIRY_TIME , BaseStorageClient
7+ from chainlit .data .storage_clients .base import BaseStorageClient , storage_expiry_time
88from chainlit .logger import logger
99
1010
@@ -29,7 +29,7 @@ def __init__(
2929
3030 def sync_get_read_url (self , object_key : str ) -> str :
3131 return self .bucket .blob (object_key ).generate_signed_url (
32- version = "v4" , expiration = EXPIRY_TIME , method = "GET"
32+ version = "v4" , expiration = storage_expiry_time , method = "GET"
3333 )
3434
3535 async def get_read_url (self , object_key : str ) -> str :
Original file line number Diff line number Diff line change 33import boto3 # type: ignore
44
55from chainlit import make_async
6- from chainlit .data .storage_clients .base import EXPIRY_TIME , BaseStorageClient
6+ from chainlit .data .storage_clients .base import BaseStorageClient , storage_expiry_time
77from chainlit .logger import logger
88
99
@@ -25,7 +25,7 @@ def sync_get_read_url(self, object_key: str) -> str:
2525 url = self .client .generate_presigned_url (
2626 "get_object" ,
2727 Params = {"Bucket" : self .bucket , "Key" : object_key },
28- ExpiresIn = EXPIRY_TIME ,
28+ ExpiresIn = storage_expiry_time ,
2929 )
3030 return url
3131 except Exception as e :
You can’t perform that action at this time.
0 commit comments