Azure PUT Blob authentication fails in R

后端 未结 2 776
谎友^
谎友^ 2021-01-23 07:29

I would like to use R and the Azure Storage\'s Put Blob API to put files into my blob storage account but it fails to authenticate my request. Unfortunately, I couldn\'t find an

相关标签:
2条回答
  • 2021-01-23 07:32

    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.

    0 讨论(0)
  • 2021-01-23 07:51

    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)
    
    0 讨论(0)
提交回复
热议问题