Re: Using DotNetZip to compress file during upload

  •  12-14-2008, 2:03 PM

    Re: Using DotNetZip to compress file during upload

    Well, it kind of worked. I just found that files that are uploaded and zipped can't be downloaded from the webpage or ftp. I checked the file permissions on the files as opposed to the files that weren't zipped and the username for that website doesn't have permissions on the zipped files. Can you tell me what I would need to do to ensure the same permissions as AjaxUploaded applies to files? Here is my code:

    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");

    }
     
    Thanks
View Complete Thread