python - Upload file to Flask API via Laravel HTTP Client
one text
I'm try to upload a file to my Flask API, via Laravel's HTTP Client
But the flask is returning null
.
This is the Flask endpoint
@app.route(f"{base_url}/submit-csv", methods=["POST"])
def process_file():
return request.files["file"].filename
If eveything works fine, it should return the filename as response.
It works perfectly fine, If I try to upload the file via Postman.
But while using Laravel HTTP Client it doesn't work.
$file = fopen($input_file_full_path, 'r');
$response = Http::asForm()
->attach('file', $file, 'file.csv')
->post("$flask_host/api/scripts/FAO/submit-csv")
->json();
I don't know, what I'm doing wrong.
Source