-
Notifications
You must be signed in to change notification settings - Fork 31
FileStore
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
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 need 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.