fix: changed workspace id to slug

This commit is contained in:
NarayanBavisetti 2023-11-13 14:36:07 +05:30
parent 77b7d43042
commit 0fe3dfddc6
2 changed files with 5 additions and 5 deletions

View File

@ -20,7 +20,7 @@ urlpatterns = [
name="file-assets", name="file-assets",
), ),
path( path(
"<uuid:workspace_id>/<str:asset_key>/", "<str:slug>/<str:asset_key>/",
AssetsEndpoint.as_view(), AssetsEndpoint.as_view(),
name="file-assets", name="file-assets",
), ),

View File

@ -80,10 +80,10 @@ class AssetsEndpoint(BaseAPIView):
permission_classes = [WorkspaceEntityPermission] permission_classes = [WorkspaceEntityPermission]
parser_classes = (MultiPartParser, FormParser) parser_classes = (MultiPartParser, FormParser)
def get(self, request, workspace_id, asset_key): def get(self, request, slug, asset_key):
workspace = Workspace.objects.get(slug=slug)
asset_key = str(workspace_id) + "/" + asset_key asset_key = str(workspace.id) + "/" + asset_key
file_asset = FileAsset.objects.get(workspace_id=workspace_id,asset=asset_key) file_asset = FileAsset.objects.get(workspace_id=workspace.id, asset=asset_key)
response = StreamingHttpResponse(file_asset.asset.open(mode='rb'), content_type='application/octet-stream') response = StreamingHttpResponse(file_asset.asset.open(mode='rb'), content_type='application/octet-stream')
return response return response