/** * Downloads one file by providing the name of the bucket and the name of the file. * * * @param String $downloadURL Obtained from b2AuthorizeAccount call * @param string $bucketName The bucket name of file * @param string $fileName The name of the file, in percent-encoded UTF-8 * @param string $token Can be null if your bucket is public otherwise An upload authorization token from authorization request * @param bool $metadataOnly True for headers array, False for content too * * @return B2Response * * @throws B2Exception */ public function b2DownloadFileByName($downloadURL, $bucketName, $fileName, $token = null, $metadataOnly = false) { $uri = $downloadURL . '/file/' . $bucketName . '/' . $fileName; $curl = $this->prepareCurl(); if (is_null($token)) { $curl->setVerifyPeer(false); // ensure it. } $browser = new Browser($curl); if (is_null($token)) { $headers = []; } else { $headers = $this->getHeaders($token); } $response = $metadataOnly ? $browser->head($uri, $headers) : $browser->get($uri, $headers); return new B2Response($response, false); }