Django Загрузка zip-файла, содержащего несколько url с изображениями

У меня есть следующий код

class getData(APIView):
    permission_classes = [AllowAny]
    file_loc = "csv/1 პრიორიტეტი - 1 პრიორიტეტი.csv"
    def get(self, request, *args, **kwargs):
        data = {}
        with open(self.file_loc, 'r', newline='') as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                code = row['ISBN']
                url = row['ყდის ფაილი']
                data[code] = url

    file2 = open(self.file_loc)
    reader = csv.reader(file2)
    lines = len(list(reader))
    some = 0


    while some != lines:
        for k,v in data.items():
            print(k, 'Da', v)
            response = HttpResponse(
            content=requests.get(v).content,
            content_type='image/jpeg',
            headers={"Content-Disposition": "attachment; filename={}".format(k+'.jpg')},
            )
            some+=1

            return response

with the following code i have keys and values for dictionary data, keys are image names and values are url of image. all im trying to do is when someone sends get request to that value(url), download all images with keys(imageNames). the problem i have is it send only one response and dont go through data items the best solution would be save those images with its names to hard drive and on GET request download zip file containing all the data. any ideas?

Вернуться на верх