Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7809565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:28:48+00:00 2026-06-02T03:28:48+00:00

In my django project i need to send a zip file to the client

  • 0

In my django project i need to send a zip file to the client side for download.This zip file would contain images downloaded from various url’s.

Is it possible to download the images in memory without writing the image files to disk then add them to a zip file in memory itself,again not writing the zip file to disk and finally sending the zip file to the client for download ?

Im aware that urllib2 can be used for image downloads and zipfile for working with zip files but facing a problem with performing these operations in memory itself.So,some example for this would be really appreciated.

Thank You

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:28:50+00:00Added an answer on June 2, 2026 at 3:28 am

    Download the file with urllib2. Open a new ZipFile for writing (you’ll need a StringIO object for this). Write the output from the url into ZilpFile.writestr. Attach zip file to django response.

    import urllib2
    from StringIO import StringIO
    
    url = urllib2.urlopen('http://example.com/foo.jpg')
    f = StringIO()
    zip = zipfile.ZipFile(f, 'w')
    zip.writestr('foo.jpg', url.read())
    response = HttpResponse(f.getvalue(), content_type="application/zip")
    response['Content-Disposition'] = 'attachment; filename=foobar.zip'
    return response
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple models with generic relations from this example at the Django Project
I'm working in django project. I have 1 postgresql sql file that need to
I need to build a django project on top of an existing database. I'll
I need some opinions here. I'm working on a Django project using buildout to
I'm using a CBGV CreateView in a Django project. I need to add some
I need to have an at-home project now that I'm working on Python/Django at
My Django project's directory hierarchy looks like this: + pybsd |---+ devices |---+ templates
I need to deploy a Django project on a shared server which I have
I'm writing a django project, and I need to have a parallel thread which
I am working on a Django project, where I need to implement full text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.