Work on event launcher, files, and related
This commit is contained in:
@@ -163,13 +163,20 @@ async def download_event_file(
|
|||||||
hash_sha256 = event_file_obj.hosted_file.hash_sha256
|
hash_sha256 = event_file_obj.hosted_file.hash_sha256
|
||||||
hash_filename = hash_sha256+'.file'
|
hash_filename = hash_sha256+'.file'
|
||||||
|
|
||||||
full_subdirectory_path = os.path.join(hosted_files_path, subdir_path)
|
if subdir_path:
|
||||||
|
full_subdirectory_path = os.path.join(hosted_files_path, subdir_path)
|
||||||
|
else:
|
||||||
|
full_subdirectory_path = hosted_files_path
|
||||||
log.debug(full_subdirectory_path)
|
log.debug(full_subdirectory_path)
|
||||||
pathlib.Path(full_subdirectory_path).mkdir(parents=True, exist_ok=True)
|
pathlib.Path(full_subdirectory_path).mkdir(parents=True, exist_ok=True)
|
||||||
file_path_w_subdir = os.path.join(full_subdirectory_path, hash_filename)
|
file_path_w_subdir = os.path.join(full_subdirectory_path, hash_filename)
|
||||||
log.info(f'Full file path with subdirectory: {file_path_w_subdir}')
|
log.info(f'Full file path with subdirectory: {file_path_w_subdir}')
|
||||||
|
|
||||||
return FileResponse(file_path_w_subdir, filename=filename)
|
if os.path.exists(file_path_w_subdir):
|
||||||
|
return FileResponse(file_path_w_subdir, filename=filename)
|
||||||
|
else:
|
||||||
|
log.error(f'The hosted file was not found on the server. Hash: {hash_sha256}')
|
||||||
|
return mk_resp(data=False, status_code=400, response=commons.response, status_message='The hosted file was not found on the server.') # Bad Request
|
||||||
# ### END ### API Hosted File ### download_tmp() ###
|
# ### END ### API Hosted File ### download_tmp() ###
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user