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

  • Home
  • SEARCH
  • 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 5969653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:15:40+00:00 2026-05-22T20:15:40+00:00

I am downloading a zip file using the zend httpClient, and getting the contents

  • 0

I am downloading a zip file using the zend httpClient, and getting the contents of the file assigned to a variable as such:

$body = $response->getBody();

$body has the contents of a zip file, can it be opened without saving it as a file first, using http://php.net/manual/en/class.ziparchive.php or some other 5.2 native class?

EDIT The suggestions gave some good ideas how it may be doable without making a temporary file, but due to the fact I’ll need to be using the proxy adapter already, going to the lengths of creating an own adapter for the purpose of this, just isn’t worth it.

I ended up using the tmpname to create a tmp file (which was something I wanted to avoid, but ended up here anyway).

   if ($response->isSuccessful()){
            $tmpfile = tempnam(sys_get_temp_dir(),'Insight');
            if ($tmpfile!==false){                
                    $handle = fopen($tmpfile, "w");
                    if (fwrite($handle, $response->getBody())!==false){
                        $zip = new ZipArchive;
                        if ($zip->open($tmpfile) === TRUE) {
                            echo $zip->getFromIndex(0);
                            $zip->close();
                        } else {
                            $this->errorLog('Unable to open zip file '.$tmpfile);
                        } 

                    }else{
                        $this->errorLog('Unable to write to temporary file '.$tmpfile);
                    }
                    fclose($handle);                  
            }else{
                $this->errorLog('Unable to create temporary zip file in '.sys_get_temp_dir());
            }                          
        }else{
            $this->errorLog('Unable to download url '.$insightUrl);
        } 
  • 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-22T20:15:40+00:00Added an answer on May 22, 2026 at 8:15 pm

    I have very little knowledge of the Zend Framework, and absolutely nothing of Zend_Http_Client, but maybe you could use compression stream wrappers when initializing the Zend_Http_Client like this:

    $client = new Zend_Http_Client('zip://http://example.org/compressed_file.zip');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to download a zip file using HttpCLient 4 and it is
I'm using python to programatically download a zip file from a web server. Using
I am trying to get a file size of remote file compiler-latest.zip (googlecode.com) using
When downloading a file with Response.Write spaces in the file name are replaced with
I am downloading a text-file from example.com/test.txt and I need the contents only during
How can i view rar or zip file content before downloading it ?
After downloading all .NET framework symbols and sources using NetMassDownloader , is it possible
I am downloading a text string from a web service into an RBuf8 using
Part of the functionality Ive written for an app is downloading zip files from
I'm trying to use the following code to create a zip file from a

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.