Skip to content

VladVega/pushToUrbanAirship

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uploadToCloudinaryGridfs

Upload files from multipart form content to Cloudinary and Gridfs simultaneously.

##Example:

var mongodb= require('mongodb'),
    Express= require('express'),
    UploadStreamMiddleware= require('./../gridUploader')
    http= require('http');

var mongoUrl= 'yourMongoUrl',
    cloudinaryConf={
        cloud_name: 'yourCloudinaryName',
        api_key: 'yourApiKey',
        api_secret: 'yourApiSecret'
    };

var app = Express();

http.createServer(app).listen(5001, function(err){
    if(err) return console.log('Server start error:',err);

    mongodb.connect(mongoUrl , function(err, db){
        if(err) return console.log('Mongo connect error:',err);

        var uploadMiddlewareFunction= UploadStreamMiddleware(db,cloudinaryConf);

        app.post('/upload', uploadMiddlewareFunction, function(req, res, next) {
            console.log('File meta and storage ids:',req.fileInfoArr);
            res.json({file_data: req.fileInfoArr});
        });

        console.log('Ready for uploads.')
    });
});

About

Communicate with urban airship.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published