How do I get a temporary File object (of correct content-type, without writing to disk) directly from a ZipEntry (RubyZip, Paperclip, Rails 3)?
问题 I'm currently trying to attach image files to a model directly from a zip file (i.e. without first saving them on a disk). It seems like there should be a clearer way of converting a ZipEntry to a Tempfile or File that can be stored in memory to be passed to another method or object that knows what to do with it. Here's my code: def extract (file = nil) Zip::ZipFile.open(file) { |zip_file| zip_file.each { |image| photo = self.photos.build # photo.image = image # this doesn't work # photo