sweets-brittle

0.11.0 • Public • Published

Discontinued! Check Matter In Motion framework.

Brittle

File uploads and processing

File upload

Brittle accepts files via XHR2.

Settings

this.file = {
  options: {
    url: '/static/uploads',                     // file urls
    path: path.join(home, 'static', 'uploads'), // files storage root.
    media: path.join(this.mediaPath, 'mask'),   // path to masks etc.
    processors: [ 'image' ]                     // processors to load
  },
 
  images: {                                     // name of job settings
    types: [ 'jpg', 'gif', 'png' ],             // file types to be accepted
    path: 'nodes/:year/:month',                 // files storage path (:year, :month, :day will be replaced with current date parts)
    jobs: [
      { 'image:resize': { name: 'l', width: 2400, height: 1600, quality: 50, crop: 'fit', upscale: false } },
      { 'image:resize': { name: 'm', width: 1200, height: 800, quality: 70, crop: 'fit', upscale: false } }
    ]
  }
};

File processors

Brittle has only one built-in processor fs with the following methods:

  • copy copies file
  • move moves file
  • mkdir makes directory recursively
  • delete deletes file

External processors:

For processors methods and options go to processors docs.

API

Brittle is presented by file resource.

process

{
  job: "name of the job to process files with"
  ratio: "force aspect ratio for image resize processor"
}

Package Sidebar

Install

npm i sweets-brittle

Weekly Downloads

0

Version

0.11.0

License

MIT

Last publish

Collaborators

  • velocityzen