cortexlabs/cortex

Async multi-part form data

ShantanuNair opened this issue · 2 comments

I'm using the AsyncApi and am trying to send a multi-part form file. It works locally when running the built docker image, but 404s on the cluster. In the logs I see

error | invalid response from user container; got status code 404, expected status code 200
errorVerbose | invalid response from user container; got status code 404, expected status code 200%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference)

My request:

curl -X POST -F file=@small.wav http://xxx-xxx.elb.us-east-1.amazonaws.com/diarizer

And, in my predictor, I parse it like:

@app.route("/", methods=["POST"])
def prediction():
    file = request.files['file']
    print("Predicting for received file: ", file.filename)

Is this not supported? how do I pass in a file payload to the AsyncAPI?

Related: #1959

Only JSON is currently supported. As a workaround, If you need to pass some sort of binary data to the API you can upload it first to s3, send the URI to that file in the payload, and process it in the API.

As an update on this, form data is supported for making the request. Only JSON data is supported for the API's response.