forked from github/plane
fix: file asset uploading and deleting (#496)
This commit is contained in:
parent
f615f8ac0c
commit
27b1308227
@ -814,7 +814,7 @@ urlpatterns = [
|
|||||||
name="user-file-assets",
|
name="user-file-assets",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"users/file-assets/user-profile/<str:asset_key>/",
|
"users/file-assets/<str:asset_key>/",
|
||||||
UserAssetsEndpoint.as_view(),
|
UserAssetsEndpoint.as_view(),
|
||||||
name="user-file-assets",
|
name="user-file-assets",
|
||||||
),
|
),
|
||||||
|
@ -91,8 +91,6 @@ class UserAssetsEndpoint(BaseAPIView):
|
|||||||
|
|
||||||
def delete(self, request, asset_key):
|
def delete(self, request, asset_key):
|
||||||
try:
|
try:
|
||||||
asset_key = "user-profile" + "/" + asset_key
|
|
||||||
print(asset_key)
|
|
||||||
file_asset = FileAsset.objects.get(asset=asset_key, created_by=request.user)
|
file_asset = FileAsset.objects.get(asset=asset_key, created_by=request.user)
|
||||||
# Delete the file from storage
|
# Delete the file from storage
|
||||||
file_asset.asset.delete(save=False)
|
file_asset.asset.delete(save=False)
|
||||||
|
@ -12,7 +12,7 @@ from . import BaseModel
|
|||||||
def get_upload_path(instance, filename):
|
def get_upload_path(instance, filename):
|
||||||
if instance.workspace_id is not None:
|
if instance.workspace_id is not None:
|
||||||
return f"{instance.workspace.id}/{uuid4().hex}-{filename}"
|
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):
|
def file_size(value):
|
||||||
|
Loading…
Reference in New Issue
Block a user