Working on range request and seeking for file downloads and streaming

This commit is contained in:
Scott Idem
2023-08-18 11:07:39 -04:00
parent 79ea4a9856
commit d59956942d

View File

@@ -201,10 +201,10 @@ async def download_hosted_file(
log.info(f'Full file path with subdirectory: {file_path_w_subdir}') log.info(f'Full file path with subdirectory: {file_path_w_subdir}')
if os.path.exists(file_path_w_subdir): if os.path.exists(file_path_w_subdir):
# log.info('Hosted file found on server.')
# return FileResponse(file_path_w_subdir, filename=filename)
log.info('Hosted file found on server.') log.info('Hosted file found on server.')
return FileResponse(file_path_w_subdir, filename=filename)
# log.info('Hosted file found on server.')
# if streaming: # if streaming:
# log.warning('Streaming!!!') # log.warning('Streaming!!!')
# def iterfile(): # # def iterfile(): #
@@ -212,8 +212,6 @@ async def download_hosted_file(
# yield from file_like # # yield from file_like #
# return StreamingResponse(iterfile(), media_type='video/mp4') # return StreamingResponse(iterfile(), media_type='video/mp4')
# else: # else:
return FileResponse(file_path_w_subdir, filename=filename)
else: else:
log.error(f'The hosted file was not found on the server. Hash: {hash_sha256}') log.error(f'The hosted file was not found on the server. Hash: {hash_sha256}')
return mk_resp(data=None, status_code=404, response=commons.response, status_message=f'The hosted file was not found on the server. Hash: {hash_sha256}') # Not Found return mk_resp(data=None, status_code=404, response=commons.response, status_message=f'The hosted file was not found on the server. Hash: {hash_sha256}') # Not Found