コード例 #1
0
        public override Stream GetStream(HttpContent parent, HttpContentHeaders headers)
        {
            ContentDispositionHeaderValue contentDisposition = headers.ContentDisposition;

            if (contentDisposition != null)
            {
                // Found a file! Track it, and ultimately upload to blob store.
                if (!String.IsNullOrWhiteSpace(contentDisposition.FileName))
                {
                    var fileInfo   = new FileInfo(contentDisposition.FileName.Trim('"'));
                    var blobStream = new MultipartBlobStream(this.imageBlobContainer, fileInfo.Name, fileInfo.Extension);
                    this.FormFiles[fileInfo.Name] = blobStream;
                    return(blobStream);
                }
                else
                {
                    return(new MemoryStream());
                }
            }
            else
            {
                throw new InvalidOperationException("No 'Content-Disposition' header");
            }
        }
コード例 #2
0
 public override Stream GetStream(HttpContent parent, HttpContentHeaders headers)
 {
     ContentDispositionHeaderValue contentDisposition = headers.ContentDisposition;
     if (contentDisposition != null)
     {
         // Found a file! Track it, and ultimately upload to blob store.
         if (!String.IsNullOrWhiteSpace(contentDisposition.FileName))
         {
             var fileInfo = new FileInfo(contentDisposition.FileName.Trim('"'));
             var blobStream = new MultipartBlobStream(this.imageBlobContainer, fileInfo.Name, fileInfo.Extension);
             this.FormFiles[fileInfo.Name] = blobStream;
             return blobStream;
         }
         else
         {
             return new MemoryStream();
         }
     }
     else
     {
         throw new InvalidOperationException("No 'Content-Disposition' header");
     }
 }