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);
}