How to upload Flask FIleStorage object file to another API?

44 Views Asked by At

I am creating an API in Flask where the user uploads file to the /upload endpoint. On receiving the file from Flask API, I want to upload the image file to imageKit API directly without first saving it on device and then reading with open() function.

Here's what I tried:

/upload API endpoint:

@app.route('/upload', methods=['POST'])
def picture_upload():
    file = request.files['file']
    response = webz.picture_upload(file)
    return "Awesome", 200

webz.py

def picture_upload(file):
    imagekit.upload(
        file = file.read(),
        file_name = "profile.png",
    )
    return True

enter image description here

But it creates a file of 41 bytes when the uploaded file is of 2 MB.

0

There are 0 best solutions below