我正在使用ng-flow将图像上传到我的webAPI,如下所示:
<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>
和
$scope.config = {
query: function (flowFile, flowChunk) {
// function will be called for every request
return {
id: 2, source: 'flow_query'
};
}
};
问题是我如何访问&#39; id&#39;我的api控制器里面的参数,我试过访问Content-D。没有运气:
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"));
答案 0 :(得分:1)
这花了太长时间:
var provider = new MultipartFormDataStreamProvider(root);
var x = provider.FormData["id"];