Topic: Save zip to db then extract it later
So I upload a zipfile and in my controller do
infile = params[:file]
@job = BackgroundJob.new
@job.filename = infile.original_filename
@job.content_type = infile.content_type
@job.data = infile.read
@job.saveThen I want to read that @job.data and do some stuff with it
f=BackgroundJob.find 59
@junk=unzip(f.data)The unzip function
def unzip(zip_source)
first_time=true
Zip::ZipFile.open(zip_source) do |zip_file|
zip_file.each do |f|
if first_time
first_time=false
return f.get_input_stream.read
end
end
end
nil
endBut gems/rubyzip-0.9.9/lib/zip/zip_file.rb:65 returns the error string contains null byte
Can someone help me?