Sha256: fcb24fa13c8c4584dc78efa086bef6b6147c161c5f50eabe6fbcb846b6d736ce
Contents?: true
Size: 949 Bytes
Versions: 2
Compression:
Stored size: 949 Bytes
Contents
module Ddr class File < Valkyrie::Resource attribute :digest, Valkyrie::Types::Set.of(Ddr::Digest) attribute :file_identifier, Valkyrie::Types::ID attribute :media_type, Valkyrie::Types::Strict::String.optional attribute :original_filename, Valkyrie::Types::Strict::String DEFAULT_FILE_EXTENSION = 'bin' def content file.read end def file Ddr.storage_adapter.find_by(id: file_identifier) end def file_created_at ::File::Stat.new(Ddr.storage_adapter.file_path(file_identifier)).ctime end def file_size file.size end # Return default file extension for file based on MIME type def default_file_extension mimetypes = MIME::Types[media_type] return mimetypes.first.extensions.first unless mimetypes.empty? case media_type when 'application/n-triples' 'txt' else DEFAULT_FILE_EXTENSION end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ddr-core-0.2.2 | app/models/ddr/file.rb |
ddr-core-0.2.1 | app/models/ddr/file.rb |