From 27b130822790ecaabc05d0660a044df670a56904 Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Wed, 22 Mar 2023 23:38:47 +0530 Subject: [PATCH] fix: file asset uploading and deleting (#496) --- apiserver/plane/api/urls.py | 2 +- apiserver/plane/api/views/asset.py | 2 -- apiserver/plane/db/models/asset.py | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apiserver/plane/api/urls.py b/apiserver/plane/api/urls.py index bf713a927..69df81c9e 100644 --- a/apiserver/plane/api/urls.py +++ b/apiserver/plane/api/urls.py @@ -814,7 +814,7 @@ urlpatterns = [ name="user-file-assets", ), path( - "users/file-assets/user-profile//", + "users/file-assets//", UserAssetsEndpoint.as_view(), name="user-file-assets", ), diff --git a/apiserver/plane/api/views/asset.py b/apiserver/plane/api/views/asset.py index be464c2d4..abdee4812 100644 --- a/apiserver/plane/api/views/asset.py +++ b/apiserver/plane/api/views/asset.py @@ -91,8 +91,6 @@ class UserAssetsEndpoint(BaseAPIView): def delete(self, request, asset_key): try: - asset_key = "user-profile" + "/" + asset_key - print(asset_key) file_asset = FileAsset.objects.get(asset=asset_key, created_by=request.user) # Delete the file from storage file_asset.asset.delete(save=False) diff --git a/apiserver/plane/db/models/asset.py b/apiserver/plane/db/models/asset.py index eba8beefc..acbb9428f 100644 --- a/apiserver/plane/db/models/asset.py +++ b/apiserver/plane/db/models/asset.py @@ -12,7 +12,7 @@ from . import BaseModel def get_upload_path(instance, filename): if instance.workspace_id is not None: return f"{instance.workspace.id}/{uuid4().hex}-{filename}" - return f"user-profile/{uuid4().hex}-{filename}" + return f"user-{uuid4().hex}-{filename}" def file_size(value):