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

发布于 2024-07-14 06:52:37 字数 449 浏览 4 评论 0原文

我正在使用 DotNetZip,并注意到我在 Mac 上遇到了权限问题。 这似乎只在我使用内容处置时才会发生。

即,如果我只是将其保存到磁盘

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

,但如果我像这样使用内容配置,则在 mac 上用户权限将被拒绝(每个组都未选中)

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

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

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))
{
    // 
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

韬韬不绝 2024-07-21 06:52:37

您可以尝试将 ApplicationType 更改为“application/octet-stream”。 不管你相信与否,这之前已经解决了我的问题。 无论如何,这都值得一试。

最大的问题是Mac端如何请求文件? 如果是 Windows Web 服务器提供文件,Windows 无法在客户端设置权限。 如果它是网络浏览器(Safari/Firefox),它们可能只是在默认设置上运行。 因此,了解从 Mac 请求文件的内容有助于获得正确的答案。

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.

稚然 2024-07-21 06:52:37

造成这种情况的原因可能有多种,但我的猜测是 Mac 上的框架存在错误。 在 Mac 上,我假设您使用的是 Mono,因此请联系 Mono 小组,看看他们有什么要说的。 他们还有一个相当不错的论坛看看他们有什么要说的。

最后,如果您在使用“内容处置”时遇到错误,请不要使用“内容处置”,并使用它的工作方式。

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.

酒浓于脸红 2024-07-21 06:52:37

我不知道它是否与 DotNetZip 有关,但现在该库有更高版本 - v1.7。 它可以进行 AES 加密、ZIP64 以及其他一些功能。
v1.8 版本具有一些新的很酷的 Seelctor 功能,以及 GZipStream 的替代品。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文