var StorageService = require('../').StorageService; var express = require('express'); var app = express(); app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); app.set('view engine', 'ejs'); // Create the container var mkdirp = require('mkdirp'); mkdirp.sync('/tmp/storage/con1'); var handler = new StorageService({provider: 'filesystem', root: '/tmp/storage'}); app.get('/', function(req, res, next) { res.setHeader('Content-Type', 'text/html'); var form = "
" + "Upload to container con1:
" + "
" + ""; res.send(form); res.end(); }); app.post('/upload/:container', function(req, res, next) { handler.upload(req, res, function(err, result) { if (!err) { res.setHeader('Content-Type', 'application/json'); res.status(200).send(result); } else { res.status(500).send(err); } }); }); app.get('/download', function(req, res, next) { handler.getContainers(function(err, containers) { var html = "