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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:29:18+00:00 2026-05-11T02:29:18+00:00

I am trying to decompress some MMS messages sent to me zipped. The problem

  • 0

I am trying to decompress some MMS messages sent to me zipped. The problem is that sometimes it works, and others not. And when it doesnt work, the python zipfile module complains and says that it is a bad zip file. But the zipfile decompresses fine using the unix unzip command.

This is what ive got

zippedfile = open('%stemp/tempfile.zip' % settings.MEDIA_ROOT, 'w+') zippedfile.write(string) z = zipfile.ZipFile(zippedfile) 

I am using ‘w+’ and writing a string to it, the string contains a base64 decoded string representation of a zip file.

Then I do like this:

filelist = z.infolist()   images = []    for f in filelist:       raw_mimetype = mimetypes.guess_type(f.filename)[0]       if raw_mimetype:           mimetype = raw_mimetype.split('/')[0]       else:           mimetype = 'unknown'       if mimetype == 'image':           images.append(f.filename)   

This way I’ve got a list of all the images in the zip file. But this doesnt always work, since the zipfile module complains about some of the files.

Is there a way to do this, without using the zipfile module?

Could I somehow use the unix command unzip instead of zipfile and then to the same thing to retrive all the images from the archive?

  • 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. 2026-05-11T02:29:19+00:00Added an answer on May 11, 2026 at 2:29 am

    You should very probably open the file in binary mode, when writing zipped data into it. That is, you should use

    zippedfile = open('%stemp/tempfile.zip' % settings.MEDIA_ROOT, 'wb+') 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decompress some large file sent by a server and then, after
I'm trying to decompress a GZipStream. The problem is that the Length property on
I am currently trying to decompress some data that I have coming in with
I have a problem trying to decompress (in Java) a string that was compressed
I'm trying to compress HTML with JavaScript and decompress it with Ruby. Some carachters
I am trying to decompress some zlib data using the dataByDecompressingData: method from ObjectiveZlib
I've got some strange problem with GZip Serializer. Trying serializing object with data in
I'm trying to decompress a file that was compressed using the DEFLATE algorithm and
I'm trying to decompress gzipped data with Inflater . According to the docs, If
Trying to build out an exception if move.UserId does not equal currentUserId then Redirect

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.