Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rposbo
Created October 16, 2014 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rposbo/2859e10bbf24ea2b689d to your computer and use it in GitHub Desktop.
Save rposbo/2859e10bbf24ea2b689d to your computer and use it in GitHub Desktop.
A basic script to upload local files to blob storage, settings ContentType correctly for png and jpeg
Param(
[string]$rootDir,
[string]$storage,
[string]$key,
[string]$container
)
try {
$context = New-AzureStorageContext -StorageAccountName $storage -StorageAccountKey $key
foreach ($file in Get-ChildItem -Path $rootDir)
{
$prop = @{"ContentType"="application/octetstream"}
if ($file.Extension.ToLowerInvariant() -eq ".png")
{
$prop = @{"ContentType"="image/png"}
}
if ($file.Extension.ToLowerInvariant() -eq ".jpg")
{
$prop = @{"ContentType"="image/jpeg"}
}
Set-AzureStorageBlobContent -Blob $file.Name -Container $container -File $file.FullName -Context $context -Properties $prop -Force
}
}
catch [System.Exception] {
Write-Host $_.Exception.ToString()
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment