All Projects β†’ veliovgroup β†’ Meteor Files

veliovgroup / Meteor Files

Licence: bsd-3-clause
πŸš€ Upload files via DDP or HTTP to β˜„οΈ Meteor server FS, AWS, GridFS, DropBox or Google Drive. Fast, secure and robust.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Meteor Files

Meteor-Files-Demo
Demo application for ostrio:files package
Stars: ✭ 16 (-98.45%)
Mutual labels:  dropbox, meteor, aws-s3
Meteor-Files-Demos
Demos for ostrio:files package
Stars: ✭ 51 (-95.06%)
Mutual labels:  meteor, upload, file-upload
Phpmussel
PHP-based anti-virus anti-trojan anti-malware solution.
Stars: ✭ 337 (-67.38%)
Mutual labels:  hacktoberfest, upload, file-upload
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+646.56%)
Mutual labels:  aws-s3, hacktoberfest
Cj Upload
Higher order React components for file uploading (with progress) react file upload
Stars: ✭ 589 (-42.98%)
Mutual labels:  upload, file-upload
Meteor Collection Hooks
Meteor Collection Hooks
Stars: ✭ 641 (-37.95%)
Mutual labels:  hacktoberfest, meteor
Meteor Publish Composite
Meteor.publishComposite provides a flexible way to publish a set of related documents from various collections using a reactive join
Stars: ✭ 546 (-47.14%)
Mutual labels:  hacktoberfest, meteor
Mongol Meteor Explore Minimongo Devtools
In-App MongoDB Editor for Meteor (Meteor DevTools)
Stars: ✭ 846 (-18.1%)
Mutual labels:  meteor, meteor-package
Vue Meteor
🌠 Vue first-class integration in Meteor
Stars: ✭ 893 (-13.55%)
Mutual labels:  meteor, meteor-package
Ostrio Analytics
πŸ“Š Visitor's analytics tracking code for ostr.io service
Stars: ✭ 9 (-99.13%)
Mutual labels:  meteor, meteor-package
Laravel Guided Image
Simplified and ready image manipulation for Laravel through intervention image.
Stars: ✭ 32 (-96.9%)
Mutual labels:  hacktoberfest, upload
Ffsend
πŸ“¬ Easily and securely share files from the command line. A fully featured Firefox Send client.
Stars: ✭ 5,448 (+427.4%)
Mutual labels:  hacktoberfest, file-upload
Pup
The Ultimate Boilerplate for Products.
Stars: ✭ 563 (-45.5%)
Mutual labels:  meteor, websockets
Chibisafe
Blazing fast file uploader and awesome bunker written in node! πŸš€
Stars: ✭ 657 (-36.4%)
Mutual labels:  upload, file-upload
Meteor User Status
Track user connection state and inactivity in Meteor.
Stars: ✭ 555 (-46.27%)
Mutual labels:  hacktoberfest, meteor
Meteor Roles
Authorization package for Meteor, compatible with built-in accounts packages
Stars: ✭ 916 (-11.33%)
Mutual labels:  hacktoberfest, meteor
Rocket.chat
The communications platform that puts data protection first.
Stars: ✭ 31,251 (+2925.27%)
Mutual labels:  hacktoberfest, meteor
Autocms
AutoCms is a simple solution for your Meteor.js app
Stars: ✭ 34 (-96.71%)
Mutual labels:  meteor, meteor-package
Blaze
⚑ File sharing progressive web app built using WebTorrent and WebSockets
Stars: ✭ 991 (-4.07%)
Mutual labels:  hacktoberfest, websockets
Laravel Mediable
Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel 5.
Stars: ✭ 541 (-47.63%)
Mutual labels:  hacktoberfest, file-upload

support support Mentioned in Awesome ostrio:files Gitter GitHub stars

Files for Meteor.js

Stable, fast, robust, and well-maintained Meteor.js package for files management using MongoDB Collection API. What does exactly this means? Calling .insert() method would initiate a file upload and then insert new record into collection. Calling .remove() method would erase stored file and record from MongoDB Collection. And so on, no need to learn new APIs. It's flavored with extra low-level methods like .unlink() and .write() for complex integrations.

ToC:

Why Meteor-Files?

Installation:

meteor add ostrio:files

ES6 Import:

import { FilesCollection } from 'meteor/ostrio:files';

API overview (full API)

new FilesCollection([config]) [Isomorphic]

Read full docs for FilesCollection Constructor

Shared code:

import { Meteor } from 'meteor/meteor';
import { FilesCollection } from 'meteor/ostrio:files';

const Images = new FilesCollection({
  collectionName: 'Images',
  allowClientCode: false, // Disallow remove files from Client
  onBeforeUpload(file) {
    // Allow upload files under 10MB, and only in png/jpg/jpeg formats
    if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) {
      return true;
    }
    return 'Please upload image, with size equal or less than 10MB';
  }
});

if (Meteor.isClient) {
  Meteor.subscribe('files.images.all');
}

if (Meteor.isServer) {
  Meteor.publish('files.images.all', function () {
    return Images.find().cursor;
  });
}

insert(settings[, autoStart]) [Client]

Read full docs for insert() method

Upload form (template):

<template name="uploadForm">
  {{#with currentUpload}}
    Uploading <b>{{file.name}}</b>:
    <span id="progress">{{progress.get}}%</span>
  {{else}}
    <input id="fileInput" type="file" />
  {{/with}}
</template>

Shared code:

import { FilesCollection } from 'meteor/ostrio:files';
const Images = new FilesCollection({collectionName: 'Images'});
export default Images; // import in other files

Client's code:

import { Template }    from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
Template.uploadForm.onCreated(function () {
  this.currentUpload = new ReactiveVar(false);
});

Template.uploadForm.helpers({
  currentUpload() {
    return Template.instance().currentUpload.get();
  }
});

Template.uploadForm.events({
  'change #fileInput'(e, template) {
    if (e.currentTarget.files && e.currentTarget.files[0]) {
      // We upload only one file, in case
      // multiple files were selected
      const upload = Images.insert({
        file: e.currentTarget.files[0],
        chunkSize: 'dynamic'
      }, false);

      upload.on('start', function () {
        template.currentUpload.set(this);
      });

      upload.on('end', function (error, fileObj) {
        if (error) {
          alert(`Error during upload: ${error}`);
        } else {
          alert(`File "${fileObj.name}" successfully uploaded`);
        }
        template.currentUpload.set(false);
      });

      upload.start();
    }
  }
});

For multiple file upload see this demo code.

Upload base64 string (introduced in v1.7.1):

// As dataURI
Images.insert({
  file: 'data:image/png,base64str…',
  isBase64: true, // <β€” Mandatory
  fileName: 'pic.png' // <β€” Mandatory
});

// As plain base64:
Images.insert({
  file: 'base64str…',
  isBase64: true, // <β€” Mandatory
  fileName: 'pic.png', // <β€” Mandatory
  type: 'image/png' // <β€” Mandatory
});

For more expressive example see Upload demo app

Stream files

To display files you can use fileURL template helper or .link() method of FileCursor.

Template:

<template name='file'>
  <img src="{{imageFile.link}}" alt="{{imageFile.name}}" />
  <!-- Same as: -->
  <!-- <img src="{{fileURL imageFile}}" alt="{{imageFile.name}}" /> -->
  <hr>
  <video height="auto" controls="controls">
    <source src="{{videoFile.link}}?play=true" type="{{videoFile.type}}" />
    <!-- Same as: -->
    <!-- <source src="{{fileURL videoFile}}?play=true" type="{{videoFile.type}}" /> -->
  </video>
</template>

Shared code:

import { Meteor } from 'meteor/meteor';
import { FilesCollection } from 'meteor/ostrio:files';

const Images = new FilesCollection({collectionName: 'Images'});
const Videos = new FilesCollection({collectionName: 'Videos'});

if (Meteor.isServer) {
  // Upload sample files on server's startup:
  Meteor.startup(() => {
    Images.load('https://raw.githubusercontent.com/VeliovGroup/Meteor-Files/master/logo.png', {
      fileName: 'logo.png'
    });
    Videos.load('http://www.sample-videos.com/video/mp4/240/big_buck_bunny_240p_5mb.mp4', {
      fileName: 'Big-Buck-Bunny.mp4'
    });
  });

  Meteor.publish('files.images.all', function () {
    return Images.find().cursor;
  });

  Meteor.publish('files.videos.all', function () {
    return Videos.find().cursor;
  });
} else {
  // Subscribe to file's collections on Client
  Meteor.subscribe('files.images.all');
  Meteor.subscribe('files.videos.all');
}

Client's code:

Template.file.helpers({
  imageFile() {
    return Images.findOne();
  },
  videoFile() {
    return Videos.findOne();
  }
});

For more expressive example see Streaming demo app

Download button

Template:

<template name='file'>
  <a href="{{file.link}}?download=true" download="{{file.name}}" target="_parent">
    {{file.name}}
  </a>
</template>

Shared code:

import { Meteor } from 'meteor/meteor';
import { FilesCollection } from 'meteor/ostrio:files';
const Images = new FilesCollection({collectionName: 'Images'});

if (Meteor.isServer) {
  // Load sample image into FilesCollection on server's startup:
  Meteor.startup(function () {
    Images.load('https://raw.githubusercontent.com/VeliovGroup/Meteor-Files/master/logo.png', {
      fileName: 'logo.png',
      meta: {}
    });
  });

  Meteor.publish('files.images.all', function () {
    return Images.find().cursor;
  });
} else {
  // Subscribe on the client
  Meteor.subscribe('files.images.all');
}

Client's code:

Template.file.helpers({
  fileRef() {
    return Images.findOne();
  }
});

For more expressive example see Download demo

FAQ:

  1. Where are files stored by default?: by default if config.storagePath isn't passed into Constructor it's equals to assets/app/uploads and relative to running script:
    • a. On development stage: yourDevAppDir/.meteor/local/build/programs/server. Note: All files will be removed as soon as your application rebuilds or you run meteor reset. To keep your storage persistent during development use an absolute path outside of your project folder, e.g. /data directory.
    • b. On production: yourProdAppDir/programs/server. Note: If using MeteorUp (MUP), Docker volumes must to be added to mup.json, see MUP usage
  2. Cordova usage and development: With support of community we do regular testing on virtual and real devices. To make sure Meteor-Files library runs smoothly in Cordova environment β€” enable withCredentials; enable {allowQueryStringCookies: true} and {allowedOrigins: true} on both Client and Server. For more details read Cookie's repository FAQ
  3. How to pause/continue upload and get progress/speed/remaining time?: see Object returned from insert method
  4. When using any of accounts packages - package accounts-base must be explicitly added to .meteor/packages above ostrio:files
  5. cURL/POST uploads - Take a look on POST-Example by @noris666
  6. In Safari (Mobile and Desktop) for DDP chunk size is reduced by algorithm, due to error thrown if frame is too big. Limit simultaneous uploads to 6 is recommended for Safari. This issue should be fixed in Safari 11. Switching to http transport (which has no such issue) is recommended for Safari. See #458
  7. Make sure you're using single domain for the Meteor app, and the same domain for hosting Meteor-Files endpoints, see #737 for details
  8. When proxying requests to Meteor-Files endpoint make sure protocol http/1.1 is used, see #742 for details

Awards:

Get Support:

Demo application:

Related Packages:

Support Meteor-Files project:

Contribution:

  • Want to help? Please check issues for open and tagged as help wanted issues;
  • Want to contribute? Read and follow PR rules. All PRs are welcome on dev branch. Please, always give expressive description to your changes and additions.

Supporters:

We would like to thank everyone who support this project. Because of those guys this project can have 100% of our attention.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].