0

Express.js backend is getting an uploaded file from client and it should pass this file to Flask service. I am able to get uploaded file as JSON in Express backend and then I can pass it to Flask service. After that I like to upload it using request.files, but this object returns empty. Then I tried to get json data using request.get_json(force=True) I can get the JSON file that is like below

{
    'name':'filename.pdf',
    'data':Buffer
    'size':328727,
    'encoding':'7bit',
    'tempFilePath':'',
    'truncated':False
    'mimetype':'application/pdf'
    'md5':'d199d18721a2118114e994a76f0c90c9'
}

Since request.files is empty, I like to use request.get_json(force=True) JSON object to upload file. My question is how can I use this JSON object in order to upload file?

davidism
  • 121,510
  • 29
  • 395
  • 339
hcacode
  • 75
  • 1
  • 9
  • How are you uploading files to the flask server? You are probably not getting anything because you're not sending a `multipart/form-data` request. Please give us more code/details. – DaCurse Sep 28 '21 at 11:56
  • User can upload a file which is send to express.js backend. This express.js backend then passes this file to flask service. I can get file express.js using `req.files.file` and pass it to Flask service, however `request.files` returns empty as I mentioned above. Thus, I decided to get data using `request.get_json(force=True)`. Can I use this buffer data to upload file? More details can be found [my other stackoverflow question](https://stackoverflow.com/questions/69358771/how-to-send-file-from-express-js-backend-to-flask-service) @DaCurse – hcacode Sep 28 '21 at 12:03

0 Answers0