Skip to content
Patrick Hochstenbach edited this page Jun 21, 2017 · 20 revisions

Stores are Catmandu packages to store Catmandu Items in a database. A FileStore is a Store where you can store binary content (unstructured data). The plan is to implement different kind of FileStore backends for Catmandu to store files in many type of systems. Out of the box, one FileStore implementation is provided: File::Simple which stores files in a directory structure on the local file system.

The command below stores the /tmp/myfile.txt in the File::Simple FileStore:

$ catmandu stream /tmp/myfile.txt to File::Simple --root t/data --bag 1234 --id myfile.txt

The root parameter is mandatory for the File::Simple FileStore. It defines the location where all stored files are written. The other two parameters bag and id are mandatory for every FileStore (see below).

To extract a file from a FileStore the stream command can be used in the opposite direction:

$ catmandu stream File::Simple --root t/data --bag 1234 --id myfile.txt to /tmp/myfile.txt

From the File::Simple store a the file myfile.txt is extracted from the Bag with identifier 1234

Bag

A FileStore contain one or more Bags. These are containers (or "folders") that contain zero or more files. The name of these container is an identifiers. In the case of the File::Simple this identifier needs to be a number, or when setting the uuid option an UUID identifier.

The binary data stored in these Bags also needs an identifier, indicated with the id option. Usually the file name is a good identifier to use.

Both the bag name option and id option are required when uploading or streaming data from a FileStore Bag.

Index

Every FileStore has a default bag called index which contains a list of all available Bags in the store. Using the export command a listing of bags can be requested from the FileStore:

$ catmandu export File::Simple --root t/data to YAML

To retrieve a listing of all files stored in a bag the bag option needs to be provided:

$ catmandu export File::Simple --root t/data --bag 1234 to YAML
Clone this wiki locally