@@ -475,45 +475,46 @@ async def update_asset_metadata(
475475 raise HTTPException (status_code = 500 , detail = str (e ))
476476
477477
478- @router .get ("/asset/{media_type}/{blob_name:path}" )
479- async def get_asset_content (
480- media_type : MediaType ,
481- blob_name : str ,
482- azure_storage_service : AzureBlobStorageService = Depends (
483- lambda : AzureBlobStorageService ())
484- ):
485- """
486- Stream asset content (image or video) directly from Azure Blob Storage
487-
488- This endpoint acts as a proxy to bypass CORS restrictions and authentication requirements
489- for Azure Blob Storage assets.
490-
491- The blob_name parameter can include folder paths.
492- For example: folder/subfolder/image.jpg
493- """
494- try :
495- # Determine container name based on media type
496- container_name = settings .AZURE_BLOB_IMAGE_CONTAINER if media_type == MediaType .IMAGE else settings .AZURE_BLOB_VIDEO_CONTAINER
497-
498- # Get the asset content
499- content , content_type = azure_storage_service .get_asset_content (
500- blob_name , container_name )
501-
502- if not content :
503- raise HTTPException (
504- status_code = 404 , detail = f"Asset not found: { blob_name } " )
505-
506- # Get just the filename without the folder path for the Content-Disposition header
507- filename = blob_name .split ('/' )[- 1 ] if '/' in blob_name else blob_name
508-
509- # Return the content as a streaming response
510- return StreamingResponse (
511- content = io .BytesIO (content ),
512- media_type = content_type ,
513- headers = {"Content-Disposition" : f"inline; filename={ filename } " }
514- )
515- except Exception as e :
516- raise HTTPException (status_code = 500 , detail = str (e ))
478+ # @router.get("/asset/{media_type}/{blob_name:path}")
479+ # async def get_asset_content(
480+ # media_type: MediaType,
481+ # blob_name: str,
482+ # azure_storage_service: AzureBlobStorageService = Depends(
483+ # lambda: AzureBlobStorageService())
484+ # ):
485+ # """
486+ # Stream asset content (image or video) directly from Azure Blob Storage
487+ #
488+ # DEPRECATED: This endpoint is disabled. Use direct SAS token access instead.
489+ # This endpoint previously acted as a proxy to bypass CORS restrictions and authentication requirements
490+ # for Azure Blob Storage assets.
491+ #
492+ # The blob_name parameter can include folder paths.
493+ # For example: folder/subfolder/image.jpg
494+ # """
495+ # try:
496+ # # Determine container name based on media type
497+ # container_name = settings.AZURE_BLOB_IMAGE_CONTAINER if media_type == MediaType.IMAGE else settings.AZURE_BLOB_VIDEO_CONTAINER
498+ #
499+ # # Get the asset content
500+ # content, content_type = azure_storage_service.get_asset_content(
501+ # blob_name, container_name)
502+ #
503+ # if not content:
504+ # raise HTTPException(
505+ # status_code=404, detail=f"Asset not found: {blob_name}")
506+ #
507+ # # Get just the filename without the folder path for the Content-Disposition header
508+ # filename = blob_name.split('/')[-1] if '/' in blob_name else blob_name
509+ #
510+ # # Return the content as a streaming response
511+ # return StreamingResponse(
512+ # content=io.BytesIO(content),
513+ # media_type=content_type,
514+ # headers={"Content-Disposition": f"inline; filename={filename}"}
515+ # )
516+ # except Exception as e:
517+ # raise HTTPException(status_code=500, detail=str(e))
517518
518519
519520@router .get ("/folders" , response_model = Dict [str , Any ])
@@ -638,7 +639,16 @@ async def create_folder(
638639 "is_folder_marker" : "true" ,
639640 "folder_path" : normalized_path
640641 }
641- blob_client .upload_blob (data = b"" , overwrite = True , metadata = metadata )
642+
643+ # Preprocess metadata values to ensure Azure compatibility
644+ processed_metadata = {}
645+ for k , v in metadata .items ():
646+ if v is not None :
647+ processed_metadata [k ] = azure_storage_service ._preprocess_metadata_value (
648+ str (v ))
649+
650+ blob_client .upload_blob (data = b"" , overwrite = True ,
651+ metadata = processed_metadata )
642652
643653 return {
644654 "success" : True ,
@@ -684,13 +694,20 @@ async def _move_asset_background(
684694 # Update metadata with new folder path
685695 metadata ['folder_path' ] = normalized_folder
686696
697+ # Preprocess metadata values to ensure Azure compatibility
698+ processed_metadata = {}
699+ for k , v in metadata .items ():
700+ if v is not None :
701+ processed_metadata [k ] = azure_storage_service ._preprocess_metadata_value (
702+ str (v ))
703+
687704 # Set content type
688705 from azure .storage .blob import ContentSettings
689706 content_settings = ContentSettings (content_type = content_type )
690707
691708 # Upload to new location
692709 blob_client .upload_blob (data = content , overwrite = True ,
693- metadata = metadata , content_settings = content_settings )
710+ metadata = processed_metadata , content_settings = content_settings )
694711
695712 # Delete original blob after successful copy
696713 azure_storage_service .delete_asset (blob_name , container_name )
@@ -762,10 +779,18 @@ async def move_asset(
762779 "is_folder_marker" : "true" ,
763780 "folder_path" : normalized_folder
764781 }
782+
783+ # Preprocess metadata values to ensure Azure compatibility
784+ processed_marker_metadata = {}
785+ for k , v in marker_metadata .items ():
786+ if v is not None :
787+ processed_marker_metadata [k ] = azure_storage_service ._preprocess_metadata_value (
788+ str (v ))
789+
765790 folder_blob_client = container_client .get_blob_client (
766791 folder_marker )
767792 folder_blob_client .upload_blob (
768- data = b"" , overwrite = True , metadata = marker_metadata )
793+ data = b"" , overwrite = True , metadata = processed_marker_metadata )
769794
770795 # Check if target already exists (to avoid overwrite if interrupted)
771796 try :
0 commit comments