MIniMagick::Image.write() 以不同的权限保存文件

发布于 2024-12-29 08:23:55 字数 454 浏览 3 评论 0原文

我正在用 Rails 3.0.11 和 MiniMagick 编写一个小照片库。

def JadeImage.rescale path,new_path,max_height=150
    image = MiniMagick::Image.open(path)
    image.adaptive_resize(self.resize(image[:height],max_height))if image[:height] > max_height
    image.write(new_path)
  end

我用它来保存同一张照片中的两个调整大小的图像。其中一个文件以 644 权限保存,一切正常。另一个总是保存为600,因此无法在网页中显示。

现在,保存它们后,我运行一个小实用程序将该目录中的所有内容设置为 644,这样它现在就可以工作了。

有什么原因会发生这种情况吗?

I am writing a little photo gallery with Rails 3.0.11 and MiniMagick.

def JadeImage.rescale path,new_path,max_height=150
    image = MiniMagick::Image.open(path)
    image.adaptive_resize(self.resize(image[:height],max_height))if image[:height] > max_height
    image.write(new_path)
  end

I am using this to save two resized images from the same photo. One of the files gets saved with 644 permissions and all is right in the world. The other always get saved as 600 and as such can't be displayed in the webpage.

For now, after saving them, I run a little utility to set everything in that directory as 644 so it works now.

Is there any reason why this would occur?

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

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

发布评论

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

评论(1

め七分饶幸 2025-01-05 08:23:55

这就是我最终解决这个问题的方法。如果您使用 apache 尝试添加到您的 apache2.conf

PassengerUserSwitching Off
PassengerDefaultUser www-data   
PassengerDefaultGroup www-data

This is how I resolved this issue on my end. If you are using apache try adding to your apache2.conf

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