mp3 files zipped change permissions compared to mp3 not zipped

Dec 13, 2008 at 7:47 PM
Edited Dec 13, 2008 at 7:47 PM
I'm using the dotnetzip in conjunction with a file uploader control in an aspx page and it works great. The only problem I have run into is that when an .mp3 is zipped ( client insists that this happens ) then the zip file cannot be downloaded via a web page or ftp and it cannot be deleted via ftp. It works fine on my developement computer. The live site is on a Window 2008 server. If I go to the server I can delete it there and when I check permissions, it doesn't have permissions for the website user/ftp name like all the other files have. Can you suggest a solution?
I have tried it with file.ForceNoCompression = true; and file.ForceNoCompression = false:
Thanks

Coordinator
Dec 13, 2008 at 9:56 PM
Is the DotNetZip library really central to the problem?  Sounds to me like the ASPX page creates a file, and that file has permissions that don't work very well for other purposes.
Does it really matter if the file is created via the DotNetZip library?  What if you just created the file manually with System.IO.File.Open or Create calls?   Are the permissions set properly then?

If I understand your problem correctly, then it really should not matter whether there is compression or not. 

anyway it sounds like you need to experiment further.
Dec 14, 2008 at 6:53 PM
The Dotnetzip was the last customization I added to the code. The files are uploaded by the customer from a webpage using the AjaxUploader.com uploader. I got that all working and then the client wanted all the files except jpg and pdf zipped as they were uploaded. AjaxUploader recommended DotNetZip. I just checked again and realized that .mp3 files were the only ones I had tried using compression. I just uploaded a .zip file and used compression and it has the same problem. So it wasn't just mp3 files. I must be doing something wrong with permissions or neglecting to do something. If the files are uploaded as they are, then they can be downloaded . Here is part of the code I am using-- can you see that I am using the zip in an incorrect way? I'm at a loss as to what to check since I'm not familiar with filestreams. 

 

void Uploader_FileUploaded(object sender, UploaderEventArgs args)

 

{

 

Uploader uploader = (Uploader)sender;

 

uploader.SetAdvancedOption(

UploaderAdvancedOption.NoFlash10, "true");

 

InsertMsg(

"File uploaded! " + args.FileName + ", " + args.FileSize + " bytes.");

 

 

string selectedItem = DropDownListTemplateFields.SelectedItem.Text.ToString();

 

selectedItem =

StringHelper.Replace(selectedItem, " ", "");

 

 

string folder = Server.MapPath("~/Assets/OrderUploads");

 

 

string thisOrderId = OrderId.ToString();

 

 

string pathURL = "../Assets/OrderUploads/";

 

 

string fileName = thisOrderId + "-" + DateTime.Now.ToString("yyyyMMddHmm") + "-" + selectedItem + "-" + args.FileName;

 

 

string zipFileName = "";

 

 

string mypath = Path.Combine(folder, fileName);

 

 

string extension = Path.GetExtension(mypath);

 

 

if (extension == ".pdf" || extension == ".jpg" || extension == ".zip")

 

{

args.CopyTo(mypath);

zipFileName = fileName;

 

}

 

else if(extension == ".mp3" || extension == ".m4a")

 

{

Ionic.Utils.Zip.

ZipFile file = new Ionic.Utils.Zip.ZipFile(Response.OutputStream);

 

file.AddFileStream(args.FileName,

"", args.OpenStream());

 

file.ForceNoCompression =

true;

 

zipFileName = fileName +

".zip";

 

file.Save(mypath +

".zip");

 

 

}

 

else

 

{

Ionic.Utils.Zip.

ZipFile file = new Ionic.Utils.Zip.ZipFile(Response.OutputStream);

 

file.AddFileStream(args.FileName,

"", args.OpenStream());

 

zipFileName = fileName +

".zip";

 

file.Save(mypath +

".zip");

 

}

Dec 16, 2008 at 10:58 PM
I found the answer in this topic:
http://www.codeplex.com/DotNetZip/Thread/View.aspx?ThreadId=39117

Once I changed the temp path, it worked fine.