Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
Created April 20, 2017 18:13
Show Gist options
  • Select an option

  • Save gregjhogan/ef37c38371193c8e9d08d867c05ad210 to your computer and use it in GitHub Desktop.

Select an option

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

pipern commented May 1, 2018

Copy link
Copy Markdown

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
Copy Markdown

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

@jdnichollsc

Copy link
Copy Markdown

works perfect, thanks!

@sbonds

sbonds commented Jul 20, 2019

Copy link
Copy Markdown

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

@sbonds

sbonds commented Jul 20, 2019

Copy link
Copy Markdown

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

@tpai

tpai commented Jun 24, 2021

Copy link
Copy Markdown

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
Copy Markdown

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

guoh27 commented Apr 6, 2023

Copy link
Copy Markdown

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