fix: file asset uploading and deleting (#496)

This commit is contained in:
pablohashescobar 2023-03-22 23:38:47 +05:30 committed by GitHub
parent f615f8ac0c
commit 27b1308227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 4 deletions

View File

@ -814,7 +814,7 @@ urlpatterns = [
name="user-file-assets",
),
path(
"users/file-assets/user-profile/<str:asset_key>/",
"users/file-assets/<str:asset_key>/",
UserAssetsEndpoint.as_view(),
name="user-file-assets",
),

View File

@ -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)

View File

@ -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):