/** * Create temporary stream * * @return resource */ protected function openTempStream() { $this->streamName = $this->config['outputstream']; if (!is_string($this->streamName)) { // If name is not given, create temp name $this->streamName = tempnam(isset($this->config['streamtmpdir']) ? $this->config['streamtmpdir'] : sys_get_temp_dir(), 'Zend\\Http\\Client'); } if (false === ($fp = @fopen($this->streamName, "w+b"))) { if ($this->adapter instanceof Client\Adapter) { $this->adapter->close(); } throw new Exception\RuntimeException("Could not open temp file {$this->streamName}"); } return $fp; }