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

meteor-uploadable

v0.1.18

Published

A package for uploading files and linking them to other models

Downloads

46

Readme

Uploadable

A package enabling the upload and linking of files to models. For example a post in a feed could files attached to it. This package takes care of uploading (using edgee:slingshot), authorising (using coniel:can) and linking the file to a model simply by passing in an instance of the model.

UploadableModel

UploadableModel is used to add uploading capabilities to a model that is built on the coniel:base-model class. To make a model uploadable just call UploadableModel.makeUploadable(Model, "typeAsString", options) passing in a model class, a string that will be used to tag the comment records for later retrieval and optional options.

var Post = BaseModel.extendAndSetupCollection("posts");

UploadableModel.makeUploadable(Post, "post");

This will add the following methods to the prototype of the model.

files(sortKey, sortOrder) - returns an array of files that are linked to this instance of a model.

images(sortKey, sortOrder) - returns an array of files which are images that are linked to this instance of a model.

fileUploads(sortKey, sortOrder) - returns an array of edge:slingshot upload objects that are linked with this instance of a model.

fileCount() - returns the number of files for this instance of a model.

FileUpload

The FileUpload class handles the actual uploading. It uses [edgee:slingshot] to perform the upload so you will need to configure it first (check out the slingshot docs on how to do that).

To upload a file and attach it to a model instance, call FileUpload(model, files, slingshotDirectiveName, callbacks);

model - the model to which you want to link the file(s).

files - an array of files (e.g. taken from a file input on change: event.target.files).

slingshotDirectiveName - the slingshot directive used to enforce rules (such as file type and max size) on the file upload. These are defined when configuring slingshot (check the slingshot docs).

callbacks - an object containing callback methods to call at different stages of the upload (see example below).

var post = Meteor.posts.findOne();

var callbacks = {
    onUploadSuccess: (file) => {
        console.log('upload succeeded');
    },
    onUploadStart: (file) => {
        console.log('upload started');
    },
    onUploadError: (error, file) => {
        console.log('upload failed');
    }
};�

FileUpload.upload(post, files, "image", callbacks);�

File - Extends LinkableModel - Implements UploadableModel

A file is a record of a an uploaded file containing meta data such as its size, mime type, original name...

Instance Methods

user() - Returns an instance of the user that uploaded the file.