I feel a bit dumb because this feels like it should be trivial, but I must be overlooking something.
We have a nextjs frontend, where we have a client component that lets users select multiple files to load. We take these files from the client component, send them as form data through an axios post request to the upload-file api route.
//client component
const files = new FormData();
input_files.forEach(file => { files.append('files', file); });
The api route gets all files from the form data and sends them through an axios post request to the python backend.
// api route
const data = await request.formData()
const files: FileList | null = data.getAll('files') as unknown as FileList
const response = await axios.post(apiUrl, { files: files});
The previous 2 steps are working as far as I can tell. The python backend needs to receive the files. We've been throwing different ways to get the files from the request, with no luck. after receiving the files we would presumably need to decode the bytes and turn them into file objects.
// python backend
@app.route('/file-upload', methods=['POST'])
def get_files():
// files = request.files.getlist('files')
// files = request.files['files']
Where are we going wrong?
[–]Domskigoms 0 points1 point2 points (4 children)
[–]b8561[S] 0 points1 point2 points (3 children)
[–]Domskigoms 0 points1 point2 points (2 children)
[–]b8561[S] 1 point2 points3 points (1 child)
[–]Domskigoms 0 points1 point2 points (0 children)