backblaze-b2 icon indicating copy to clipboard operation
backblaze-b2 copied to clipboard

Download URL incorrect if we need to authorize

Open bittylicious opened this issue 5 years ago • 1 comments

When trying to download a B2 file using the Client::download function, I've noticed that we can overwrite the hostname we're connecting to, leaving just the path.

cURL will then correctly complain that an invalid URL is given. That's because we're asking for /b2api/v1/b2_download_file_by_id?whatever instead of https://xxxx.backblazeb2.com/b2api/v1/b2_download_file_by_id?whatever

I think that I only see this because I'm passing in an invalid token, but I think the bug is still valid.

To fix this, I think we need to change src/Client.php's download function and move $this->authorizeAccount() above the if (isset($options['FileId'])) and $requestOptions = [ ... ] blocks. authorizeAccount can set the class's downloadUrl and authToken variables, and we're relying on these in this function.

bittylicious avatar Oct 24 '20 12:10 bittylicious

Hi @bittylicious would https://github.com/gliterd/backblaze-b2/pull/61 solve this problem? It sets the download url properly by calling authorizeAccount first.

mlambley avatar Jan 28 '21 05:01 mlambley