[
  {
    "Id": "819090",
    "ThreadId": "350974",
    "Html": "\r\n<p>My plan is first - Have an FileUploadControl to upload the file, but the uploaded file SHOULD BE SAVE as a Stream.</p>\r\n<p>Then - The uploadedfile (Already a Stream)&nbsp;should be ZIP</p>\r\n<p>Then - The uploadedfile&nbsp;(Already a Stream and already ZIP) should be able to save inside the Blob Storage in Azure.</p>\r\n<p>The code below is somehow working because when i look on the Blob storage, i was able to see the uploaded file and the size of the file has already change (Become smaller) &nbsp;and it has the zip extension on it, but when i try to get the file and try to\r\n manually extract the file,&nbsp;it is corrupted. </p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre><span style=\"color:green\">// Make a unique blob name</span>\r\n            <span style=\"color:blue\">string</span> extension = System.IO.Path.GetExtension(fileUploadControl.FileName);\r\n            <span style=\"color:blue\">string</span> filenameonly = System.IO.Path.GetFileNameWithoutExtension(fileUploadControl.FileName) &#43; <span style=\"color:#a31515\">&quot;1&quot;</span>;\r\n            <span style=\"color:blue\">string</span> location = System.IO.Path.GetFullPath(fileUploadControl.PostedFile.FileName);\r\n            <span style=\"color:blue\">string</span> fileName = Guid.NewGuid() &#43; extension;\r\n\r\n            MemoryStream s = <span style=\"color:blue\">new</span> MemoryStream(fileUploadControl.FileBytes);\r\n            s.Flush();\r\n            s.Seek(0, SeekOrigin.Begin);\r\n\r\n            <span style=\"color:blue\">using</span> (ZipFile zip = <span style=\"color:blue\">new</span> ZipFile())\r\n            {\r\n                ZipEntry ze = zip.AddEntry(filenameonly &#43; <span style=\"color:#a31515\">&quot;.zip&quot;</span>, s);\r\n                <span style=\"color:green\">//zip.AddFile(fileUploadControl.FileName);</span>\r\n                Response.ClearContent();\r\n                Response.ClearHeaders();\r\n                Response.ContentType = <span style=\"color:#a31515\">&quot;application/zip&quot;</span>;\r\n                Response.AppendHeader(<span style=\"color:#a31515\">&quot;content-disposition&quot;</span>, <span style=\"color:#a31515\">&quot;attachment; filename=&quot;</span> &#43; filenameonly &#43; <span style=\"color:#a31515\">&quot;.zip&quot;</span>);\r\n                zip.Save(s);\r\n            }\r\n            Response.Write(s);\r\n            <span style=\"color:blue\">var</span> blob = _BlobContainer.GetBlobReference(filenameonly &#43; <span style=\"color:#a31515\">&quot;.zip&quot;</span>);\r\n            blob.UploadFromStream(s);\r\n\r\n            <span style=\"color:green\">// Set the metadata into the blob</span>\r\n            blob.Metadata[<span style=\"color:#a31515\">&quot;FileName&quot;</span>] = fileUploadControl.FileName;\r\n            blob.Metadata[<span style=\"color:#a31515\">&quot;Submitter&quot;</span>] = submitterBox.Text;\r\n            blob.SetMetadata();\r\n\r\n            <span style=\"color:green\">// Set the properties</span>\r\n            blob.Properties.ContentType = fileUploadControl.PostedFile.ContentType;\r\n            blob.SetProperties();\r\n</pre>\r\n</div>\r\nPlease help me with this.\r\n<p></p>\r\n",
    "PostedDate": "2012-04-02T23:48:08.163-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]