I am sending file in formData
from typescript using Fetch API and hitting FastAPI to upload the file to amazon s3. When I am using the api docs it is working and flie is uploading but then I am hitting it with fetch error is coming -> There was an error parsing the body
.
On the typescript side...
var formData = new FormData();
formData.append('file', files[0]);
const requestOptions = {
method: requestMethod,
headers:
{
'Content-Type': 'multipart/form-data',
'Authorization': `Bearer ${token}`,
},
body : formData,
async: false,
contentType: false,
processData: false,
};
let response = await fetch(url, requestOptions);
On FastAPI side...
@router.post("/Upload_video_to_s3_for_module")
async def upload_video_to_s3_for_module(
*,
db: Session = Depends(deps.get_db),
file: UploadFile = File(...),
) -> Any:
// code to upload the video file.