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)