我在照片共享网站上,我想提供下载图库中所有可用图像的功能,我已经在相关的图库中获取了@ gallery.uploads所有的图片,
现在我想要的是下载所有文件,或者如果它可以创建任何zip文件,以便我们可以下载包含上传库内的一个文件,
谢谢
使用rubyzip gem来在服务器端创建zipfile:
require 'zip/zip'
Zip::ZipFile.open("my.zip", Zip::ZipFile::CREATE) {
|zipfile|
puts zipfile.read("first.txt")
zipfile.remove("first.txt")
}
Run Code Online (Sandbox Code Playgroud)
将图像添加到zip文件并sendfile在rails-application中使用以将文件发送到浏览器.阅读有关缺失位的文档Zip::Zipfile和sendfile缺失位.
| 归档时间: |
|
| 查看次数: |
1405 次 |
| 最近记录: |