DotNetZip: creating zip with C# permissions issue

别等时光非礼了梦想. 提交于 2021-01-29 06:48:22

问题


I am using DotNetZip and have noticed that i am getting permission issues on Mac's. This seems to only occur when i use content disposition.

ie if i just save it to disk

using (ZipFile zip = new ZipFile(@"C:\zip\temp.zip"))
{
   // this works fine
}

but if i use content disposition like so, on mac the user permissions are denied ( everyone group is unchecked)

Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "filename=" + filename);

using (ZipFile zip = new ZipFile(Response.OutputStream))
{
    // 
}

回答1:


You could try changing the ApplicationType to "application/octet-stream". Believe it or not that has fixed problems for me before. It's worth a shot anyway.

The biggest question is how is the file being requested from the Mac's side? If it's a Windows web server offering up the file, Windows can't set the permissions on the client side. If it's a web browser (Safari/Firefox) they're probably just running on the default settings. So knowing what is requesting the file from the Mac could help get the right answer.




回答2:


There could be several reasons for this but my guess would be that there is a bug in the framework on the mac. Being on a Mac I assume you are using mono so contact the Mono group and see what they have to say. Also they have a fairly good forum see what they have to say.

Finally if your getting errors using "content-disposition", then don't use "content-disposition", and use the way it works.




回答3:


I don't know if it has anything to do with DotNetZip, but there is a later version of the library out now - v1.7. It does AES encryption, ZIP64, a bunch of other stuff. And the v1.8 version has some new cool Seelctor features, as well as a replacement for GZipStream.



来源:https://stackoverflow.com/questions/606908/dotnetzip-creating-zip-with-c-sharp-permissions-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!