I am uploading 100 mb file in attachment-fu , i have given size also upto 128mb in the model file too. But when i attach zip file, the files started repeating by it self ,and if i upload same 20mb file it works perfaclty fine. And if i do this process on the server it takes so much process and load too, is there any way to solve thsi ? my code of model is
has_attachment :storage => :file_system,
:max_size => 128.megabytes
validates_as_attachment
def self.build_from_zip(ss,user,gallary)
zipfile = Zip::ZipFile.open(ss.temp_path)
zipfile.each do |entry|
if entry.name.include?("/")
entry.name = entry.name.split("/").last
entry.name = "" if entry.name.nil?
end
if entry != ""
if entry.directory?
next
elsif entry.name.include?("/")
next
else
screen =Upload.new
screen.filename = entry.name
screen.description = ss.description
screen.user_id = user
screen.gallaries = Gallary.find(gallary) if gallary
screen.temp_data = zipfile.read(entry.name)
mime = MIME::Types.type_for(entry.name)[0]
screen.content_type = mime.content_type unless mime.blank?
screen.save! unless screen.content_type.blank?
if mime.content_type.include?("video")
screen.convert
end
@upload = Upload.find_by_id(screen.id)
if @upload.content_type.include?("video")
@upload.video= 'video'
@upload.save_thumbnail
@upload.save
@thumb = Thumbnail.find_by_id(@upload.thumbnail.to_i)
@thumb.parent_id = @upload.id
@thumb.thumbnail = 'thumb'
@thumb.save
else
image = Magick::ImageList.new("public/"+ @upload.public_filename)
screen.date_taken = DateTime.strptime(image.get_exif_by_entry('DateTime')[0][1], "%Y:%m:%d %H:%M:%S") unless image.get_exif_by_entry('DateTime')[0][1].nil?
screen.model = image.get_exif_by_entry('model')[0][1]
screen.camera = image.get_exif_by_entry('make')[0][1]
screen.iso = image.get_exif_by_entry('ISOSpeedRatings')[0][1]
screen.save
end
end
end
end
end