Skip to content

UCSC-MedBook/blobs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blobs

This package allows for easy storage of blobs on the filesystem.

Getting started

Installation

This package is not currently published to Atmosphere.

cd webapp/packages
git submodule add https://github.com/UCSC-MedBook/blobs

Usage

Insert

Inserting a blob on the server will move the original file!

Blobs2.create(pathToFileOnServer, associatedObject, metadata, callback)

  • pathToFileOnServer: the path of the file on the server
  • associatedObject: the object the blob is associated with. This is an object with the fields collection_name and mongo_id.
  • metadata: any needed uniquely identifying information (any Object)
let blobId = Blobs2.create("/path/to/file/on/server", {
  collection_name: "Jobs",
  mongo_id: "YDcb7YWfXTdjXbSKX"
}, {}, function (err, result) {
  // code
});

Delete

Blobs can be deleted using Blobs2.delete, which takes a selector and a callback function.

Calling Blobs2.delete will also delete the files on disk.

let associated_object = {
  collection_name: "Jobs",
  mongo_id: "7bcYtNJx4G3NpEtCn",
}

Blobs2.delete({ associated_object }, (err, deletedCount) => {
  if (err) {
    console.log("Error deleting blobs!");
  }
});

Internal documentation

Blobs are stored at /filestore, but this can be overridden by setting MEDBOOK_FILESTORE in environment.

Within that folder, they are stored two folders down, according to the mongo _id. If the mongo _id is "abcdefg", the full storage path will be "/filestore/ab/cd/abcdefg".

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published