简体   繁体   中英

Django multiple photo download

I developed a photo gallery in python, now I want to insert a new feature, "Download Multiple Photos": a user can select some photos to download and system creates a compressed file with the photos.

In your opinion: in the frontend what is the best way to send the ids? Json? input hidden? and in the backend there is a django library that compress the selected photos and return the compressed file?

Thanks, Marco

Once you get the IDs of all the selected image in the client, you can zip them by using the zipfile or tarfile module . The way to collect the files to compress totally depends on how did you save the image. If you save the image such as uploaded date/id/, then on the client side, you need to send those information back to the server as well to reduce the server load. Hidden fields are ok in this situation

I think the only way to do it is in the backend, because in the frontend you will only have to select which photos you want to download and send the ids or some identifiers to the server side, then retrieve those selected photos from the filesystem (based on the identifiers), compress them in a single file and return that compressed file in a response as attached content.

If you do it in the front end how would you get each file and compress them all?

Doing it in server side is the best solution in my opinion :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM