ExecutePostProcessingAsync抛出索引超出范围'在Azure上传期间

时间:2016-04-23 03:49:20

标签: c# angularjs asp.net-web-api azure-storage azure-storage-blobs

尝试将表单中的文件上传到Azure Blob存储。代码似乎工作,文件正确上传。我无法弄清楚为什么它会抛出这个例外。

指数超出范围。必须是非负数且小于集合的大小。\ r \ n参数名称:index"}

public override Stream GetStream(HttpContent parent, HttpContentHeaders headers)
{
    if (parent == null)
    {
        throw new ArgumentNullException("parent");
    }
    if (headers == null)
    {
        throw new ArgumentNullException("headers");
    }

            var fileName = this.GetLocalFileName(headers);

            //BlobName = BlobName + fileName;

            CloudBlockBlob blob = this.BlobContainer.GetBlockBlobReference(fileName);
            blob.Metadata["Created"] = DateTime.Now.ToString();

            if (headers.ContentType != null)
            {
                blob.Properties.ContentType = headers.ContentType.MediaType;
            }

            this.FileData.Add(new MultipartFileData(headers, blob.Name));
            return blob.OpenWrite();

}

此处发生异常:

public override Task ExecutePostProcessingAsync()
        {

            return base.ExecutePostProcessingAsync();
        }

我的ApiController中的代码:

var provider = new AzureBlobMultipartFormDataStreamProvider(container, blobPath);
                await Request.Content.ReadAsMultipartAsync(provider);

0 个答案:

没有答案