ralphie
ralphie

Reputation: 132

Meteor with Kloudless service

I am following a jsfiddle example here where Kloudless API was used. link Kloudless API in Javascript

Using the code below with the jsfiddle code I place it on my template rendered but sadly it did not work

Template.kloudless.rendered = function() {
     var explorer = window.Kloudless.explorer({
         app_id: 'iCZ_ICMy43H0NSoz0QbLvmyjzCHf2frAOPaBfWVgh9_vrFIM',
         multiselect: true,
         computer: true
     });

    explorer.on('success', function(files) {
        $("#file-info > pre").replaceWith('<pre>' + JSON.stringify(files, null, 2) + '</pre>');
    });

    explorer.choosify($('#chooser'));

    var files = [{
        url: "https://s3-us-west-2.amazonaws.com/static-assets.kloudless.com/static/logo_white.png",
        name: "kloudless-logo.png"
    }];

    explorer.savify($("#saver"), files);
}

If I placed the the code as shown below it will work. Is there a way to write the code in a more Meteor way, like the following code?

<header> 
    <title>myapp</title>
    <script type="text/javascript">
        var explorer = window.Kloudless.explorer({
            app_id: 'iCZ_ICMy43H0NSoz0QbLvmyjzCHf2frAOPaBfWVgh9_vrFIM',
            multiselect: true,
            computer: true
        });

        explorer.on('success', function(files) {
            $("#file-info > pre").replaceWith('<pre>' + JSON.stringify(files, null, 2) + '</pre>');
        });

        explorer.choosify($('#chooser'));

        var files = [{
            url: "https://s3-us-west-2.amazonaws.com/static-assets.kloudless.com/static/logo_white.png",
            name: "kloudless-logo.png"
        }];

        explorer.savify($("#saver"), files);
    </script>
</header>

Upvotes: 2

Views: 147

Answers (1)

Kuba Wyrobek
Kuba Wyrobek

Reputation: 5273

There is npm package kloudless-meteor.

You can use it with meteor. Instruction for meteor > 0.9.0:

First add npm package:

meteor add meteorhacks:npm

Note npm packages can be used only on server side.

Create packages.json file :

{
  "kloudless-meteor":"0.0.1"
}

Then start using it on server side like this:

var kloudless = Meteor.npmRequire('kloudless')('your-api-key-here');

Documentation

 API methods are called in the scheme of... 
 kloudless.<resource>.<method>(<data-json>, <callback>);

Side note

If you want to upload files with kloudless to cloud provider ( amazon, rackspace, etc ) then first you need to upload from client to server. I recommend to do that using https://github.com/CollectionFS/Meteor-CollectionFS

Upvotes: 2

Related Questions