My plan is first - Have an FileUploadControl to upload the file, but the uploaded file SHOULD BE SAVE as a Stream.
Then - The uploadedfile (Already a Stream) should be ZIP
Then - The uploadedfile (Already a Stream and already ZIP) should be able to save inside the Blob Storage in Azure.
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) and it has the zip extension on it, but when i try to get the file and try to
manually extract the file, it is corrupted.
Please help me with this.
// Make a unique blob name
string extension = System.IO.Path.GetExtension(fileUploadControl.FileName);
string filenameonly = System.IO.Path.GetFileNameWithoutExtension(fileUploadControl.FileName) + "1";
string location = System.IO.Path.GetFullPath(fileUploadControl.PostedFile.FileName);
string fileName = Guid.NewGuid() + extension;
MemoryStream s = new MemoryStream(fileUploadControl.FileBytes);
using (ZipFile zip = new ZipFile())
ZipEntry ze = zip.AddEntry(filenameonly + ".zip", s);
Response.ContentType = "application/zip";
Response.AppendHeader("content-disposition", "attachment; filename=" + filenameonly + ".zip");
var blob = _BlobContainer.GetBlobReference(filenameonly + ".zip");
// Set the metadata into the blob
blob.Metadata["FileName"] = fileUploadControl.FileName;
blob.Metadata["Submitter"] = submitterBox.Text;
// Set the properties
blob.Properties.ContentType = fileUploadControl.PostedFile.ContentType;