I'm trying to send an array of images using fetch to a flask endpoint, but I can't seem to get the data across.
Fetch:
async () => {
const data = new FormData();
data.append('images', imagesArray);
const response = await fetch('/upload', {
method: 'POST',
body: data
});
}
Endpoint:
@main.route('/upload', methods=['POST'])
def process_image():
if request.files:
images = request.files.getlist('images[]')
print(images)
Nothing gets printed to the server. However, if I just send a single image and set
images = request.files['images']
, then the image object will be printed out.
What am I doing wrong? Any help would be much appreciated!