Sha256: 6e4b474d1e79e4cf1a43167d1f081a779e081664c14a6db600a538e8f099f0b2

Contents?: true

Size: 749 Bytes

Versions: 13

Compression:

Stored size: 749 Bytes

Contents

module Neofiles::DataStore::Mongo::FileHelper
  extend ActiveSupport::Concern

  included do
    has_many :chunks, dependent: :destroy, order: [:n, :asc], class_name: 'Neofiles::FileChunk'
    field :chunk_size, type: Integer, default: Neofiles::DataStore::Mongo::DEFAULT_CHUNK_SIZE
    validates :chunk_size, presence: true

    def self.copy_from_mongo_to_amazon_s3(ids)
      ids.each do |id|
        begin
          mongo_object = Neofiles::DataStore::Mongo.find id
          amazon_object = Neofiles::DataStore::AmazonS3.find(id) rescue nil
          Neofiles::DataStore::AmazonS3.new(id).write(mongo_object.data) unless amazon_object
        rescue Neofiles::DataStore::NotFoundException
          next
        end
      end
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
neofiles-1.3.2 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-2.2.0 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-2.1.1 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-1.3.1 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-1.3.0 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-2.1.0 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-2.0.4 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-2.0.3 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-1.2.2 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-1.2.1 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-2.0.2 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-2.0.1 app/models/concerns/neofiles/data_store/mongo/file_helper.rb
neofiles-2.0.0 app/models/concerns/neofiles/data_store/mongo/file_helper.rb