I'm using flurl in uwp, and want to post an image file to the server.
The server api needs a parameter "image_file", a binary file, need to post using multipart/form-data.
Now I have a StorageFile, how to post it?
string res = "";
try
{
res = await _detect_api_url
.PostMultipartAsync(mp => mp
.AddStringParts(new { api_key = _api_key, api_secret = _api_secret, return_landmark = returnLandmarks, return_attributes = returnAttributes })
.AddFile("image_file", imageFile)
).ReceiveString();
}
catch (FlurlHttpTimeoutException)
{
Debug.WriteLine("FlurlHttp internal time out.");
res = "FlurlHttp internal time out.";
}
catch (FlurlHttpException ex)
{
Debug.WriteLine(ex.Message);
res = ex.Call.ErrorResponseBody;
}