Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
Created April 20, 2017 18:13
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • 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}"
@pipern
Copy link

pipern commented May 1, 2018

Just FYI for future google-users who find this, unfortunately it will only work for files <= 4MB (see https://support.microsoft.com/en-gb/help/4016806/the-request-body-is-too-large-error-when-writing-data-to-azure-file )

@michaelnemtsev
Copy link

Hi, I just tested uploading 121Mb file and no issues happened. Could you advise on your settings?

@jdnichollsc
Copy link

works perfect, thanks!

@sbonds
Copy link

sbonds commented Jul 20, 2019

Tried with a 324MB file: The request body is too large and exceeds the maximum permissible limit.

@sbonds
Copy link

sbonds commented Jul 20, 2019

A workaround was to use the Azure Microsoft-provided utility blobxfer: https://github.com/Azure/blobxfer

@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