Skip to content

Commit

Permalink
avoid download
Browse files Browse the repository at this point in the history
  • Loading branch information
siyuniu-ms committed Apr 25, 2024
1 parent ab80a0b commit d5fd095
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions AISKU/scripts/publishImgToCdn.ps1
Expand Up @@ -86,7 +86,7 @@ if ([string]::IsNullOrWhiteSpace($jsSdkDir) -eq $true) {
}

$cacheControl1Year = "public, max-age=31536000, immutable, no-transform";
$contentType = "image/svg";
$contentType = "image/svg+xml;";

Write-LogParams

Expand All @@ -112,7 +112,9 @@ Write-Log "Release Files : $($releaseFiles.Count)"

Write-Log "----------------------------------------------------------------------"

$contentDisposition = "inline"

# Publish the img to the folder that is same to the script folder.
PublishFiles $releaseFiles "scripts/b" $cacheControl1Year $contentType $overwrite
PublishFiles $releaseFiles "scripts/b" $cacheControl1Year $contentType $overwrite $contentDisposition

Write-Log "======================================================================"
12 changes: 9 additions & 3 deletions common/publish/AzureStorageHelper/AzureStorageHelper.psm1
Expand Up @@ -534,9 +534,14 @@ Function CopyBlob(

Write-Log " - $($blob.Name) ==> $destName"

Write-Log "Source Blob: $sourceBlobPath"
Write-Log "Destination Blob: $destinationBlobPath"
Write-Log "Storage Context: $($storageContext.StorageAccountName)"

$srcCloudBlob = $blob.ICloudBlob.FetchAttributes()

$blobResult = Start-AzStorageBlobCopy -Context $blobContext -CloudBlob $blob.ICloudBlob -DestContext $destContext.azureContext -DestContainer "$($destContext.storageContainer)" -DestBlob $destName -Force
# $blobResult = Start-AzStorageBlobCopy -Context $blobContext -CloudBlob $blob.ICloudBlob -DestContext $destContext.azureContext -DestContainer "$($destContext.storageContainer)" -DestBlob $destName -Force
$blobResult = Start-AzStorageBlobCopy -Context $blobContext -SrcContainer $blob.ICloudBlob.Container.Name -SrcBlob $blob.ICloudBlob.Name -DestContext $destContext.azureContext -DestContainer "$($destContext.storageContainer)" -DestBlob $destName -Force
Write-LogErrors

# Don't try and publish anything if any errors have been logged
Expand Down Expand Up @@ -605,7 +610,8 @@ Function PublishFiles(
[string] $storagePath,
[string] $cacheControlValue,
[string] $defaultContentType,
[bool] $overwrite
[bool] $overwrite,
[string] $contentDisposition = $null
) {

# Don't try and publish anything if any errors have been logged
Expand Down Expand Up @@ -682,7 +688,7 @@ Function PublishFiles(
if ($null -ne $blob -and $blob.Count -ne 0) {
if ($overwrite -eq $true) {
Write-Log " Overwriting $($blobPrefix + $name)"
$newBlob = Set-AzStorageBlobContent -Force -Container $storageContainer -File $path -Blob ($blobPrefix + $name) -Context $azureContext -Properties @{CacheControl = $cacheControlValue; ContentType = $contentType} -Metadata $metadata
$newBlob = Set-AzStorageBlobContent -Force -Container $storageContainer -File $path -Blob ($blobPrefix + $name) -Context $azureContext -Properties @{CacheControl = $cacheControlValue; ContentType = $contentType; ContentDisposition = $contentDisposition} -Metadata $metadata
if ($null -eq $newBlob) {
Write-LogFailure " Failed to overwrite/upload $($blobPrefix + $name)"
}
Expand Down

0 comments on commit d5fd095

Please sign in to comment.