How to generate a zip file from given file list (Django)?

import os import shutil from io import BytesIO from zipfile import ZipFile from django.core.files.storage import FileSystemStorage from django.http import HttpResponse from django.conf import settings local_storage = FileSystemStorage() class ZipResponseMixin: def response(self, request, files: list, folder_name: str) -> HttpResponse: """Zip Response Generate a zip file from given file list and return Http response (Force download) :param request: request Object :param files: list of file like objects saved in models :param folder_name: desired folder name :return: """ folder_abs_path = f"{settings....

November 14, 2021