简体   繁体   English

DotNetZip:使用C#权限问题创建zip

[英]DotNetZip: creating zip with C# permissions issue

I am using DotNetZip and have noticed that i am getting permission issues on Mac's. 我正在使用DotNetZip,并且注意到我在Mac上遇到了权限问题。 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) 但是,如果我像这样使用内容配置,则在Mac上,用户权限被拒绝(未选中每个组)

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

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

You could try changing the ApplicationType to "application/octet-stream". 您可以尝试将ApplicationType更改为“ 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? 最大的问题是如何从Mac端请求文件? If it's a Windows web server offering up the file, Windows can't set the permissions on the client side. 如果是提供文件的Windows Web服务器,则Windows无法在客户端设置权限。 If it's a web browser (Safari/Firefox) they're probably just running on the default settings. 如果是网络浏览器(Safari / Firefox),则可能只是在默认设置下运行。 So knowing what is requesting the file from the Mac could help get the right answer. 因此,了解从Mac请求文件的内容可能有助于获得正确的答案。

There could be several reasons for this but my guess would be that there is a bug in the framework on the mac. 可能有多种原因,但我的猜测是mac上的框架中存在错误。 Being on a Mac I assume you are using mono so contact the Mono group and see what they have to say. 在Mac上,我假设您正在使用Mono,因此请与Mono组联系,看看他们怎么说。 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. 最后,如果您在使用“ content-disposition”时遇到错误,请不要使用“ content-disposition”,并使用其工作方式。

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. 我不知道它是否与DotNetZip有关,但是现在有一个更高版本的库-v1.7。 It does AES encryption, ZIP64, a bunch of other stuff. 它执行AES加密,ZIP64和许多其他功能。 And the v1.8 version has some new cool Seelctor features, as well as a replacement for GZipStream. v1.8版本具有一些新的炫酷Seelctor功能,并替代了GZipStream。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM