Closed moonhouse closed 12 years ago
We see that the data chunks for some of the files stored with GridFS in our database isn't restored properly. We can restore them manually by
require 'bson' require 'zlib' require 'digest/md5' @file_name = '/Users/david.hall/Downloads/2012-09-04_10-30-26.gz' file = Zlib::GzipReader.open(@file_name) obj = Marshal.load file.read file.close obj.each do |col_name, records| next unless col_name == 'fs.chunks' records.each do |record| if record["files_id"].to_s=='503dffd59701bf0002000004' File.open('outfile.jpg', 'w') {|f| f.write(record["data"]) } end end end
Embarrassingly enough I had a too small MongoHQ instance which fooled me since the chunks were restored at the end.
No problem. Glad you've figured it out!
We see that the data chunks for some of the files stored with GridFS in our database isn't restored properly. We can restore them manually by