Module: Valkyrie::Storage

Defined in:
lib/valkyrie/storage.rb,
lib/valkyrie/storage/disk.rb,
lib/valkyrie/storage/fedora.rb,
lib/valkyrie/storage/memory.rb,
lib/valkyrie/storage/versioned_disk.rb

Overview

Note:

These storage adapters do not store metadata See Valkyrie::Persistence for persisting metadata.

This is a namespacing module for storage adapters, which store binary content as per the DataMapper pattern

https://en.wikipedia.org/wiki/Data_mapper_pattern

Examples:

Register storage adapters in an initializer using Valkyrie::StorageAdapter.register


# Store files on local disk
Valkyrie::StorageAdapter.register(
  Valkyrie::Storage::Disk.new(base_path: '/path/to/files'),
  :disk
)

Retrieve a registered persister using Valkyrie::StorageAdapter.find


storage = Valkyrie.config.storage_adapter  # default
storage = Valkyrie::StorageAdapter.find(:disk)  # named

Save/upload a file


file_set = FileSet.new title: 'page 1'
upload = ActionDispatch::Http::UploadedFile.new tempfile: File.new('/path/to/files/file1.tiff'), filename: 'file1.tiff', type: 'image/tiff'
file = storage.upload(file: upload, resource: file_set)
file_set.file_identifiers << file.id
persister.save(resource: file_set)

See Also:

Defined Under Namespace

Classes: Disk, Fedora, Memory, VersionedDisk