1010from sentry .api .base import region_silo_endpoint
1111from sentry .api .bases .project import ProjectEndpoint
1212from sentry .models .project import Project
13- from sentry .objectstore import app_icons
13+ from sentry .objectstore import preprod
1414from sentry .objectstore .service import ClientError
1515
1616logger = logging .getLogger (__name__ )
@@ -56,7 +56,7 @@ def detect_image_content_type(image_data: bytes) -> str:
5656
5757
5858@region_silo_endpoint
59- class ProjectPreprodArtifactIconEndpoint (ProjectEndpoint ):
59+ class ProjectPreprodArtifactImageEndpoint (ProjectEndpoint ):
6060 owner = ApiOwner .EMERGE_TOOLS
6161 publish_status = {
6262 "GET" : ApiPublishStatus .EXPERIMENTAL ,
@@ -66,36 +66,36 @@ def get(
6666 self ,
6767 request : Request ,
6868 project : Project ,
69- app_icon_id : str ,
69+ image_id : str ,
7070 ) -> HttpResponse :
7171 organization_id = project .organization_id
7272 project_id = project .id
7373
74- # object_key = f"{organization_id}/{project_id}/{app_icon_id }"
74+ object_key = f"{ organization_id } /{ project_id } /{ image_id } "
7575 logger .info (
76- "Retrieving app icon from objectstore" ,
76+ "Retrieving image from objectstore" ,
7777 extra = {
7878 "organization_id" : organization_id ,
7979 "project_id" : project_id ,
80- "app_icon_id " : app_icon_id ,
80+ "image_id " : image_id ,
8181 },
8282 )
83- client = app_icons .for_project (organization_id , project_id )
83+ client = preprod .for_project (organization_id , project_id )
8484
8585 try :
86- result = client .get (app_icon_id )
86+ result = client .get (object_key )
8787 # Read the entire stream at once
8888 image_data = result .payload .read ()
8989
9090 # Detect content type from the image data
9191 content_type = detect_image_content_type (image_data )
9292
9393 logger .info (
94- "Retrieved app icon from objectstore" ,
94+ "Retrieved image from objectstore" ,
9595 extra = {
9696 "organization_id" : organization_id ,
9797 "project_id" : project_id ,
98- "app_icon_id " : app_icon_id ,
98+ "image_id " : image_id ,
9999 "size_bytes" : len (image_data ),
100100 "content_type" : content_type ,
101101 },
@@ -109,7 +109,7 @@ def get(
109109 extra = {
110110 "organization_id" : organization_id ,
111111 "project_id" : project_id ,
112- "app_icon_id " : app_icon_id ,
112+ "image_id " : image_id ,
113113 },
114114 )
115115
@@ -121,7 +121,7 @@ def get(
121121 extra = {
122122 "organization_id" : organization_id ,
123123 "project_id" : project_id ,
124- "app_icon_id " : app_icon_id ,
124+ "image_id " : image_id ,
125125 "error" : str (e ),
126126 "status" : e .status ,
127127 },
@@ -134,7 +134,7 @@ def get(
134134 extra = {
135135 "organization_id" : organization_id ,
136136 "project_id" : project_id ,
137- "app_icon_id " : app_icon_id ,
137+ "image_id " : image_id ,
138138 },
139139 )
140140 return HttpResponse ({"error" : "Internal server error" }, status = 500 )
0 commit comments