问题
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