cURL e BLOB do Azure com cabeçalho HTTP do SAS, obrigatório para essa solicitação, não especificado

1

Revisei as informações em:

Até onde eu sei, estou obedecendo, pois estou postando o SAS na URL.

Aqui está o meu script de teste simples:

#!/bin/bash

DATE_NOW=$(date -Ru | sed 's/\+0000/GMT/')
AZ_VERSION="2018-03-28"
AZ_BLOB_URL="https://XXXXXXXX.blob.core.windows.net"
AZ_BLOB_CONTAINER="XXXXXX"
AZ_BLOB_TARGET="${AZ_BLOB_URL}/${AZ_BLOB_CONTAINER}/"
AZ_SAS_TOKEN="?sv=2017-11-09&ss=b&srt=o&sp=rwlac&se=2021-11-06T01:05:33Z&st=2018-11-09T17:05:33Z&sip=192.0.2.0-192.0.2.254&spr=https&sig=XXXXXXXXXX"

curl -v -X PUT -H "Content-Type: application/octet-stream" -H "x-ms-date: ${DATE_NOW}" -H "x-ms-version: ${AZ_VERSION}" --data-binary "@/home/test/test" "${AZ_BLOB_TARGET}test${AZ_SAS_TOKEN}"

Em exibição, o resultado é:

> PUT /XXXX/XXXXX?sv=2017-11-09&ss=b&srt=o&sp=rwlac&se=2021-11-06T01:05:33Z&st=2018-11-09T17:05:33Z&sip=192.0.2.0-192.0.2.254&spr=https&sig=XXXXXXXXXX" HTTP/1.1
> Host: XXXXX.blob.core.windows.net
> User-Agent: curl/7.60.0
> Accept: */*
> Content-Type: application/octet-stream
> x-ms-date: Sat, 10 Nov 2018 17:48:06 GMT
> x-ms-version: 2018-03-28
> Content-Length: 14
> 
* upload completely sent off: 14 out of 14 bytes
< HTTP/1.1 400 An HTTP header that's mandatory for this request is not specified.
< Content-Length: 295
< Content-Type: application/xml
< Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
< x-ms-request-id: 69b144ec-b01e-0112-651d-791ccd000000
< x-ms-version: 2018-03-28
< x-ms-error-code: MissingRequiredHeader
< Date: Sat, 10 Nov 2018 17:48:06 GMT
< 
<?xml version="1.0" encoding="utf-8"?><Error><Code>MissingRequiredHeader</Code><Message>An HTTP header that's mandatory for this request is not specified.
RequestId:69b144ec-b01e-0112-651d-791ccd000000
    
por Little Code 10.11.2018 / 18:50

1 resposta

3

A resposta simples para sua pergunta é: você está com falta de -H "x-ms-blob-type: BlockBlob" .

Mas o seu SAS Token também pode ser inválido depois de corrigir o cabeçalho, você está tentando fazer o upload de um arquivo usando um token SAS que não tem acesso ao Container e pode ter restrições de IP.

Imagem 1

Imagem 2

#!/bin/bashDATE_NOW=$(date-Ru|sed's/\+0000/GMT/')AZ_VERSION="2018-03-28"
AZ_BLOB_URL="https://xxxxxx.blob.core.windows.net"
AZ_BLOB_CONTAINER="test"
AZ_BLOB_TARGET="${AZ_BLOB_URL}/${AZ_BLOB_CONTAINER}/"
AZ_SAS_TOKEN="?sv=2017-11-09&ss=b&srt=sco&sp=rwlac&se=2018-11-11T05:03:03Z&st=2018-11-10T21:03:03Z&spr=https&sig=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%3D"

curl -v -X PUT -H "Content-Type: application/octet-stream" -H "x-ms-date: ${DATE_NOW}" -H "x-ms-version: ${AZ_VERSION}" -H "x-ms-blob-type: BlockBlob" --data-binary "/temp/test.log" "${AZ_BLOB_TARGET}test.log${AZ_SAS_TOKEN}"

Espero que isso ajude.

    
por 10.11.2018 / 22:46