fix(): Ajuste de gravaçao do caminho do arquivo

This commit is contained in:
Kenio 2025-11-05 18:09:31 -03:00
parent b7d8824b50
commit e4629bb3f6

View file

@ -57,6 +57,10 @@ def _save_file_from_base64(base64_content: str, file_name: str, ato_id: int) ->
# Caminho completo do arquivo final # Caminho completo do arquivo final
file_path = target_dir / file_name file_path = target_dir / file_name
# Caminho para visualização via url (relativo ao storage)
# Exemplo: "100/57/documento.pdf"
file_url = f"{faixa_superior}/{ato_id}/{file_name}"
try: try:
# Decodifica o Base64 # Decodifica o Base64
file_bytes = base64.b64decode(base64_content) file_bytes = base64.b64decode(base64_content)
@ -65,8 +69,8 @@ def _save_file_from_base64(base64_content: str, file_name: str, ato_id: int) ->
with open(file_path, "wb") as f: with open(file_path, "wb") as f:
f.write(file_bytes) f.write(file_bytes)
# Retorna o caminho completo do arquivo salvo # Retorna o caminho completo do arquivo salvo para visualização via URl
return str(file_path) return str(file_url)
except base64.binascii.Error: except base64.binascii.Error:
raise HTTPException( raise HTTPException(