Add API for moving files (#1016)

### What problem does this PR solve?

Add backend API support for moving files into other directory

### Type of change
- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Zhedong Cen
2024-05-31 18:11:25 +08:00
committed by GitHub
parent c58a1c48eb
commit 4ec845c0a6
2 changed files with 32 additions and 1 deletions

View File

@ -343,5 +343,27 @@ def get(file_id):
'application/%s' %
ext.group(1))
return response
except Exception as e:
return server_error_response(e)
@manager.route('/mv', methods=['POST'])
@login_required
@validate_request("src_file_ids", "dest_file_id")
def move():
req = request.json
try:
file_ids = req["src_file_ids"]
parent_id = req["dest_file_id"]
for file_id in file_ids:
e, file = FileService.get_by_id(file_id)
if not e:
return get_data_error_result(retmsg="File or Folder not found!")
if not file.tenant_id:
return get_data_error_result(retmsg="Tenant not found!")
fe, _ = FileService.get_by_id(parent_id)
if not fe:
return get_data_error_result(retmsg="Parent Folder not found!")
FileService.move_file(file_ids, parent_id)
return get_json_result(data=True)
except Exception as e:
return server_error_response(e)