Spaces:
Running
Running
File size: 804 Bytes
12b0dd7 cb23311 12b0dd7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import tempfile, os
from _utils.bubble_integrations.obter_arquivo import get_pdf_from_bubble
def handle_pdf_files_from_serializer(files):
listaPDFs = []
for file in files:
file.seek(0)
with tempfile.NamedTemporaryFile(
delete=False, suffix=".pdf"
) as temp_file: # Create a temporary file to save the uploaded PDF
for (
chunk
) in file.chunks(): # Write the uploaded file content to the temporary file
temp_file.write(chunk)
temp_file_path = temp_file.name # Get the path of the temporary file
listaPDFs.append(temp_file_path)
print("listaPDFs: ", listaPDFs)
return listaPDFs
def remove_pdf_temp_files(listaPDFs):
for file in listaPDFs:
os.remove(file)
|