npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fng-jq-upload

v0.12.0-beta.301

Published

jQuery file upload plugin for forms-angular, storing data in Mongo. Pretty much a wrapper for BlueImp jquery-file-upload

Downloads

698

Readme

fng-jq-upload

jQuery file upload plugin for forms-angular, storing data in Mongo. A wrapper for BlueImp jquery-file-upload, heavily influenced Dominic Bottger's fork of that project.

Usage

npm install fng-jq-upload

To get all the dependencies at the top level of your node_modules run

npm dedupe    

On the server side:

Install ImageMagick for creating image thumbnails.

In the call to create the forms-angular object (normally in the main server express start-up module) add a plugins property to the options as follows:

var fngJqUpload = require('fng-jq-upload');
var DataFormHandler = new (formsAngular)(app, {
  plugins: {
    JQMongoFileUploader: { plugin: fngJqUpload.Controller, options: { } },
  }
});

Configuration options:

  • inhibitAuthentication : boolean. Inhibit calling any authentication middleware that forms-angular has been told to use. Prevents having to intercept http calls in BlueImp (PRs to enable this would be more than welcome).

On the client side:

Add the following lines to your index.html (or equivalent) file

<!-- blueimp Gallery styles -->
<link rel="stylesheet" href="blueimp-gallery/css/blueimp-gallery.css">
<!-- CSS to style the file input field as button and adjust the Bootstrap progress bars -->
<link rel="stylesheet" href="fng-jqfile-upload/css/jquery.fileupload.css">
<link rel="stylesheet" href="fng-jqfile-upload/css/jquery.fileupload-ui.css">

<script type="text/javascript" src="blueimp-load-image/js/load-image.min.js"></script>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script type="text/javascript" src="blueimp-canvas-to-blob/js/canvas-to-blob.min.js"></script>
<!-- blueimp Gallery script -->
<script type="text/javascript" src="blueimp-gallery/js/jquery.blueimp-gallery.min.js"></script>
<script type="text/javascript" src="fng-jq-upload/fng-jq-upload.js"></script>

Ensure that your application module (or whatever module is going to use the uploader) specifies uploadModule as a dependency.

angular.module('myApplication', ['uploadModule']);    
        

File fields need to be set up as follows:

var uploadSchema = new mongoose.Schema({
  filename: String,
  size: Number
});

var mySchema = new mongoose.Schema({
  domrField: String,
  files: {
    type: [uploadSchema],
    form: {
      directive: 'fng-jq-upload-form', 
      fngJqUploadForm: {
        sizeLimit: 5000000,
        autoUpload:true
      }
    }
  }
});

You can extend the schema and add the additFields property to the fngJqUploadForm object to generate an inline form to capture the extra fields. For example:

additFields: JSON.stringify([{name:'param'}]),

the additFields property is of type form schema.

The chunks and file details get stored in the collection.files and collection.chunks collections where 'collection' is the collection in which the data for mySchema is stored. Additional fields, if any, get stored in the main collection.

This is done using the following api endpoints:

  • POST /file/upload/:model stores the uploaded file to a model. In the case of gif, png or jpg files creates a thumbnail. Other file types get a reference to a generic file icon as a thumbnail.
  • GET /file/:model/:id retrieves a stored file
  • GET /file/:model/thumbnail/:id retrieves a thumbnail for a stored graphical file
  • DELETE /file/:model/:id deletes a stored file