@@ -7,7 +7,7 @@ import { AppError, AssetState, AssetType, ErrorCode, IAsset, StorageType, ILabel
77import { throwUnhandledRejectionForEdge } from "../../react/components/common/errorHandler/errorHandler" ;
88import { AssetService } from "../../services/assetService" ;
99import { IStorageProvider } from "./storageProviderFactory" ;
10- import { withQueueMap } from "../../common/queueMap/withQueueMap"
10+ import { withQueueMap } from "../../common/queueMap/withQueueMap"
1111
1212/**
1313 * Options for Azure Cloud Storage
@@ -156,7 +156,7 @@ export class AzureBlobStorage implements IStorageProvider {
156156 * check file is exists
157157 * @param filePath
158158 */
159- public async isFileExists ( filePath : string ) : Promise < boolean > {
159+ public async isFileExists ( filePath : string ) : Promise < boolean > {
160160 const client = this . containerClient . getBlobClient ( filePath ) ;
161161 return await client . exists ( ) ;
162162 }
@@ -234,9 +234,9 @@ export class AzureBlobStorage implements IStorageProvider {
234234 return result ;
235235 }
236236
237- public async getAsset ( folderPath : string , assetName : string ) : Promise < IAsset > {
237+ public async getAsset ( folderPath : string , assetName : string ) : Promise < IAsset > {
238238 const files : string [ ] = await this . listFiles ( folderPath ) ;
239- if ( files . findIndex ( f => f === assetName ) !== - 1 ) {
239+ if ( files . findIndex ( f => f === assetName ) !== - 1 ) {
240240 const url = this . getUrl ( assetName ) ;
241241 const asset = await AssetService . createAssetFromFilePath ( url , this . getFileName ( url ) ) ;
242242 if ( this . isSupportedAssetType ( asset . type ) ) {
@@ -270,16 +270,19 @@ export class AzureBlobStorage implements IStorageProvider {
270270 * @param url - URL for Azure Blob
271271 */
272272 public getFileName ( url : string ) {
273- const pathParts = url . split ( "/" ) ;
274- return pathParts [ pathParts . length - 1 ] . split ( "?" ) [ 0 ] ;
273+ // offset path by 2 to remove container name
274+ return new URL ( url ) . pathname . split ( '/' ) . slice ( 2 ) . join ( '/' ) ;
275275 }
276276
277277 private isSupportedAssetType ( assetType : AssetType ) {
278278 return assetType === AssetType . Image || assetType === AssetType . TIFF || assetType === AssetType . PDF ;
279279 }
280280
281281 private getUrl ( blobName : string ) : string {
282- return this . containerClient . getBlobClient ( blobName ) . url ;
282+ // Azure Storage SDK returns blob name with slashes encoded (encodeURIComponent).
283+ // Reconstruct the blob URL to use encodeURI instead
284+ const [ baseUrl , queryString ] = this . containerClient . url . split ( '?' ) ;
285+ return baseUrl + '/' + encodeURI ( blobName ) + ( queryString ? `?${ queryString } ` : '' ) ;
283286 }
284287
285288 private async blobToString ( blob : Blob ) : Promise < string > {
0 commit comments