I am using ng-flow to upload an image to my webAPI like so:
<div class="form-horizontal" role="form" flow-init="config"
flow-file-added="!!{png:1,gif:1,jpg:1,jpeg:1}[$file.getExtension()]"
flow-files-submitted="$flow.upload()">
<img flow-img="$flow.files[0]" style="max-width:150px; max-height:150px;" />
<span class="btn btn-success" flow-btn flow-attrs="{accept:'image/*'}">Upload Image</span>
</div>
and
$scope.config = {
query: function (flowFile, flowChunk) {
// function will be called for every request
return {
id: 2, source: 'flow_query'
};
}
};
The question is how do I access the 'id' parameter inside my api controller, I tried accessing Content-D. with no luck:
string root = HttpContext.Current.Server.MapPath("~/Content/Images/User");
var provider = new MultipartFormDataStreamProvider(root);
try
{
// Read the form data.
await Request.Content.ReadAsMultipartAsync(provider);
// This illustrates how to get the file names.
foreach (MultipartFileData file in provider.FileData)
{
//Console.WriteLine(file.Headers.ContentDisposition.FileName);
//Trace.WriteLine("Server file path: " + file.LocalFileName);
var PId = file.Headers.ContentDisposition.Parameters.First(x => x.Name.Contains("id"));
This took way too long:
var provider = new MultipartFormDataStreamProvider(root);
var x = provider.FormData["id"];