File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -93,3 +93,11 @@ def get(self, with_valid=True):
9393 status = 200 ,
9494 headers = {'Content-Type' : mime_types .get (file_type , 'text/plain' )}
9595 )
96+
97+ def delete (self ):
98+ self .is_valid (raise_exception = True )
99+ file_id = self .data .get ('id' )
100+ file = QuerySet (File ).filter (id = file_id ).first ()
101+ if file is not None :
102+ file .delete ()
103+ return True
Original file line number Diff line number Diff line change @@ -40,3 +40,15 @@ class Operate(APIView):
4040 )
4141 def get (self , request : Request , file_id : str ):
4242 return FileSerializer .Operate (data = {'id' : file_id }).get ()
43+
44+ @extend_schema (
45+ methods = ['DELETE' ],
46+ summary = _ ('Get file' ),
47+ description = _ ('Get file' ),
48+ operation_id = _ ('Get file' ),
49+ parameters = FileGetAPI .get_parameters (),
50+ responses = FileGetAPI .get_response (),
51+ tags = [_ ('File' )]
52+ )
53+ def delete (self , request : Request , file_id : str ):
54+ return result .success (FileSerializer .Operate (data = {'id' : file_id }).delete ())
You can’t perform that action at this time.
0 commit comments