Loading..Для добавления сообщений зарегистрируйтесь!
Ruslan Voloshin
Живет: Odessa,UKR
Сообщений: 2458
Рейтинг: 616.0
Рег: 13 марта 2007
Его блог
|
moff
Вот у меня реализован еще такой вариант
def download_client
client_type = params[:id]
if client_type.eql?('php')
file_name = "tmp/ziped_clients/#{current_user.uid}.zip"
FileUtils.remove_file(file_name, true)
=begin
Версия с созданием файла пхп архива.
=end
file = Zip::ZipFile.open(file_name, Zip::ZipFile::CREATE) {
|zipfile|
zipfile.mkdir(current_user.uid.to_s)
zipfile.add("#{current_user.uid}/client.php", "#{RAILS_ROOT}/crawler/client.php")
}
=begin
Версия с созданием пхп архива в через прямую запись в архив.
=end
# Zip::ZipOutputStream::open("my.zip"){ |io|
# io.put_next_entry("#{current_user.uid}/client.php")
# File.open("#{RAILS_ROOT}/crawler/client.php"){|f|
# f.each{|line| io.write line}}
# io
# }
send_file file_name, :size => file.size, :filename => "#{current_user.uid}.zip"
else
render :text => 'Unknown client format!!!'
end
return
|
|
Операции с WM | SEO консультации
|
|
zip ZipOutputStream ZipFile
|