Work on temporary hosted file downloads and export creation.

This commit is contained in:
Scott Idem
2021-11-23 16:51:41 -05:00
parent 4fa32f63fd
commit 24c7411109
5 changed files with 114 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ from __future__ import annotations
# import datetime, hashlib, os, pathlib, shutil, time
#from datetime import datetime, time, timedelta
from fastapi import APIRouter, Body, Depends, File, Form, Header, HTTPException, Query, Response, status, UploadFile
from fastapi.responses import FileResponse
from pydantic import BaseModel, EmailStr, Field
from typing import Dict, List, Optional, Set, Union
@@ -428,3 +429,23 @@ async def get_hosted_file_obj(
return mk_resp(data=hosted_file_dict, response=response)
#return mk_resp(data=hosted_file_obj)
# ### END ### API Hosted File ### get_hosted_file_obj() ###
# ### BEGIN ### API Hosted File ### download_tmp() ###
# Updated 2021-11-23
@router.get('/download/{filename}', response_model=Resp_Body_Base)
async def download_tmp(
filename: str = Query(..., min_length=4, max_length=100),
# x_account_id: str = Header(...),
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
response: Response = Response,
):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
full_dest_path = 'admin/temp/order_line/order_line_list_2021-11-23_1310.xlsx'
filename = 'text.xlsx'
return FileResponse(full_dest_path, filename=filename)
# ### END ### API Hosted File ### download_tmp() ###