Coder Social home page Coder Social logo

meteor-slingshot-cloudinary's Introduction

meteor add jimmiebtlr:slingshot-cloudinary

Use

Cloudinary Console

You'll need to create a upload preset in cloudinary. I belive the following options are needed.

  • Mode: Signed
  • UseFilename: true
  • UniqueFilename: No

Your app

server.js

Slingshot.fileRestrictions('videos', {
  allowedFileTypes: ['video/mp4'],
  maxSize: 500000000,
});

Slingshot.createDirective('videos', Slingshot.Cloudinary, {
  authorize() {
    if (!this.userId) {
      const message = 'Please login before posting files';
      throw new Meteor.Error('Login Required', message);
    }

    return true;
  },

  key() {
    return Meteor.uuid();
  },
});

settings.js

{
  "CloudinaryCloudName": "cloud_name",
  "CloudinarySecret": "secret",
  "CloudinaryKey": "key",
  "CloudinaryPreset": "preset"
}

File Upload Options

Cloudinary allows a number of file upload options, as documented in their nodejs API. A few of these options are supported for now.

tags (optional)

A tag name or an array with a list of tag names to assign to the uploaded image.

Slingshot.createDirective('videos', Slingshot.Cloudinary, {
    authorize() {...},
    key() {...},
    tags: ['tag1', 'tag2']
});

folder (optional)

An optional folder name where the uploaded resource will be stored. The public ID contains the full path of the uploaded resource, including the folder name.

Slingshot.createDirective('videos', Slingshot.Cloudinary, {
    authorize() {...},
    key() {...},
    folder: myFolder
});

Todo

There is still work to be done. Pull requests welcome.

  • Improve handling of video, image, and raw upload types.
  • Check that public_id is checked using the signature.
  • Implement all the file upload options supported by cloudinary

meteor-slingshot-cloudinary's People

Contributors

jimmiebtlr avatar raiyankamal avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.