Sha256: 0d66934c98237b2f557ccb8c30f20ec0bab479b828d3512adfe6a06f9096fe8f

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

module Duracloud
  class ChunkedContent < Content

    def self.find(**kwargs)
      new(**kwargs).tap do |content|
        content.manifest
      end
    end

    def manifest
      if @manifest.nil?
        @manifest = ContentManifest.find(space_id: space_id,
                                         manifest_id: content_id + MANIFEST_EXT,
                                         store_id: store_id)
        load_properties
      end
      @manifest
    end

    def chunked?
      true
    end

    private

    def do_load_properties
      if md5
        if md5 != manifest.source.md5
          raise MessageDigestError, "Expected MD5: {#{md5}}; DuraCloud MD5: {#{manifest.source.md5}}."
        end
      else
        self.md5 = manifest.source.md5
      end
      self.properties = manifest.properties.dup
      self.content_type = manifest.source.content_type
      self.size = manifest.source.size
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
duracloud-client-0.6.0 lib/duracloud/chunked_content.rb