Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 1.32 KB

README.md

File metadata and controls

54 lines (43 loc) · 1.32 KB

Mongo File Store

Mongo File Store is a library for adding small files from the filesystem to MongoDB using Mongoid.

Status

Code Climate Build Status

Install

gem install mfs

Purpose

  • Shared Set of Files
  • Attach Metadata to Files
  • Retrieve Files based on metadata

Usage

require 'mfs'
entry = Mfs::Entry.load_file('path/to/file')
entry.filepath
entry.filename
entry.created_at
entry.data

# Set arbitrary Meta-data fields
Mfs::Entry.load_file('path/to/file',test_field: true)
entry = Mfs::Entry.where(test_field: true).first

# Load all files in a directory structure
entries = Mfs::Entry.load_directory('path/to/files')

# Load all files and set meta-data
entries = Mfs::Entry.load_directory('path/to/files') do |filename|
    {has_a: filename.include('a')}
end

Create your own file types. As an example see Mfs::Types::Certificate and its Spec

Limitations

  • No File Hierarchy
  • Does not use GridFS (<16MB files only)
  • Does not check for duplicate files