Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
Created April 20, 2017 18:13
Show Gist options
  • Save gregjhogan/ef37c38371193c8e9d08d867c05ad210 to your computer and use it in GitHub Desktop.
Save gregjhogan/ef37c38371193c8e9d08d867c05ad210 to your computer and use it in GitHub Desktop.
Push a file to a blob in an Azure storage account
curl -X PUT -T ./{file.dat} -H "x-ms-date: $(date -u)" -H "x-ms-blob-type: BlockBlob" "https://{storageaccount}.blob.core.windows.net/backups/{file.dat}?{sas-token}"
@tpai
Copy link

tpai commented Jun 24, 2021

Sometimes, date -u will output invalid format on different timezone or country, an alternative way is

-H "x-ms-date: $(TZ=GMT date '+%a, %d %h %Y %H:%M:%S %Z')"

@robinlandstrom
Copy link

Had to use the following to get a x-ms-date header matching https://learn.microsoft.com/en-us/rest/api/storageservices/representation-of-date-time-values-in-headers

-H "x-ms-date: $(TZ=GMT LC_TIME=C date '+%a, %d %h %Y %H:%M:%S %Z')"

@guoh27
Copy link

guoh27 commented Apr 6, 2023

Not works: 'The value for one of the HTTP headers is not in the correct format'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment