Search code examples
rcurlazure-blob-storagercurlhttr

Downloading Azure blob using shared access signature fails with curl or httr


I've managed to download from blob storage before using curl::curl_download and httr::GET, but this time it's failing with a 400 error. However, if I use base R's download.file, it works.

The download URL is (copied verbatim, but omitting the file details and actual signature):

https://{account}.blob.core.windows.net/{store}/{file.zip}?sp=r&st=2018-05-19T00:00:00Z&se=2018-05-31T00:00:00Z&spr=https&sv=2017-07-29&sig={...}&sr=b

of which the SAS portion is

sp=r&st=2018-05-19T00:00:00Z&se=2018-05-31T00:00:00Z&spr=https&sv=2017-07-29&sig={...}&sr=b

Has anyone else come across this problem?


Solution

  • As it turns out, it had nothing to do with the SAS. The filename had a space in it, which the default download.file on Windows turns into a %20, but curl doesn't. Manually encoding the space as %20 fixed the problem.