Azure PUT Blob authentication fails in R

我们两清 提交于 2019-12-02 04:23:57

I managed to resolve this issue by putting the "\n" characters and everything in the right place. Based on Gaurav Mantri's help, I used:
https://docs.microsoft.com/en-us/rest/api/storageservices/authentication-for-the-azure-storage-services

The following changes in the 'signature_string' worked:

signature_string <- paste0("PUT", "\n",            # HTTP Verb
                           "\n",                   # Content-Encoding  
                           "\n",                   # Content-Language
                           content_length, "\n",   # Content-Length
                           "\n",                   # Content-MD5
                           "text/plain", "\n",     # Content-Type
                           "\n",                   # Date
                           "\n",                   # If-Modified-Since
                           "\n",                   # If-Match  
                           "\n",                   # If-None-Match
                           "\n",                   # If-Unmodified-Since
                           "\n",                   # Range
                           # Here comes the Canonicalized Headers
                           "x-ms-blob-type:BlockBlob","\n",
                           "x-ms-date:",requestdate,"\n",
                           "x-ms-version:2015-02-21","\n",
                           # Here comes the Canonicalized Resource
                           "/",account, "/",container,"/", filename)

There is an Azure offical R package Microsoft/AzureSMR on GitHub, which can help you easier using R & Azure Blob Storage, you can refer to its tutorial to know more details.

If you just want to use some Azure services like Blob Storage, not else, I think some source codes of this project are very valuable for rebuilding your code better, such as createAzureStorageSignature method which can directly help building the signature to resolve your issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!