att
This commit is contained in:
+18
-7
@@ -74,8 +74,13 @@ SQLSERVER_CONN = os.getenv(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
AZURE_UPLOAD_URL = "https://api.grupoginseng.com.br/portal/boletosvitrine/boleto/arquivos"
|
AZURE_PREFIX = os.getenv("AZURE_PREFIX", "Boletos/boleto")
|
||||||
AZURE_PREFIX = os.getenv("AZURE_PREFIX", "Boletos")
|
AZURE_CONTAINER_URL = "https://storageginseng.blob.core.windows.net/boletosvitrine"
|
||||||
|
AZURE_SAS_TOKEN = (
|
||||||
|
"sp=racwdl&st=2026-07-22T20:02:40Z&se=2029-12-31T04:17:40Z"
|
||||||
|
"&spr=https&sv=2026-02-06&sr=c"
|
||||||
|
"&sig=TmK3mBYoMDuRqd%2FPBhd0aNk20oV%2BBJpwlH42q%2FR7rY0%3D"
|
||||||
|
)
|
||||||
MAX_PARALLEL_REQUESTS = 5
|
MAX_PARALLEL_REQUESTS = 5
|
||||||
MAX_PARALLEL_PDFS_PER_USER = 1
|
MAX_PARALLEL_PDFS_PER_USER = 1
|
||||||
DOWNLOAD_RETRY_ATTEMPTS = 4
|
DOWNLOAD_RETRY_ATTEMPTS = 4
|
||||||
@@ -367,13 +372,19 @@ def _guess_cte_nfe_keys_from_xml_names(xml_names: List[str]) -> Dict[str, Option
|
|||||||
|
|
||||||
|
|
||||||
def upload_azure(prefix: str, filename: str, data: bytes, content_type: str) -> str:
|
def upload_azure(prefix: str, filename: str, data: bytes, content_type: str) -> str:
|
||||||
response = requests.post(
|
blob_path = f"{prefix.rstrip('/')}/{filename}"
|
||||||
AZURE_UPLOAD_URL,
|
url = f"{AZURE_CONTAINER_URL}/{blob_path}?{AZURE_SAS_TOKEN}"
|
||||||
files={"file": (filename, io.BytesIO(data), content_type)},
|
response = requests.put(
|
||||||
data={"prefix": prefix},
|
url,
|
||||||
|
data=data,
|
||||||
|
headers={
|
||||||
|
"x-ms-blob-type": "BlockBlob",
|
||||||
|
"Content-Type": content_type,
|
||||||
|
},
|
||||||
|
timeout=60,
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return f"{prefix.rstrip('/')}/{filename}"
|
return blob_path
|
||||||
|
|
||||||
|
|
||||||
def _safe_file_part(name: str) -> str:
|
def _safe_file_part(name: str) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user