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 1072541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:52:26+00:00 2026-05-16T20:52:26+00:00

In a python web application, I’m packaging up some stuff in a zip-file. I

  • 0

In a python web application, I’m packaging up some stuff in a zip-file. I want to do this completely on the fly, in memory, without touching the disk. This goes fine using ZipFile.writestr as long as I’m creating a flat directory structure, but how do I create directories inside the zip?

I’m using python2.4.

http://docs.python.org/library/zipfile.html

  • 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-05-16T20:52:26+00:00Added an answer on May 16, 2026 at 8:52 pm

    What ‘theomega’ said in the comment to my original post, adding a ‘/’ in the filename does the trick. Thanks!

    from zipfile import ZipFile
    from StringIO import StringIO
    
    inMemoryOutputFile = StringIO()
    
    zipFile = ZipFile(inMemoryOutputFile, 'w') 
    zipFile.writestr('OEBPS/content.xhtml', 'hello world')
    zipFile.close()
    
    inMemoryOutputFile.seek(0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for some recommendations for a python web application. We have some memory
I use python -m SimpleHTTPServer when I want to run my web application locally,
First, some background: I'm developing a web application using Python. All of my (text)
I've been automating some tests against a web application using Python and COM. My
I want some help on a way to transfer data from a python web
I'm writing a web-application in Python, I haven't decided if I want to use
I'm building a web application in python. A part of this application is working
Programming a Python web application, I want to create a text area where the
I have a Python web application (Django, specifically). I'm reading in some data from
I'm working on a Python web application in which I have some small modules

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.