Integrated stackedit-download-proxy service
This commit is contained in:
parent
4b875e798a
commit
7726b46be2
20
app/download.js
Normal file
20
app/download.js
Normal file
@ -0,0 +1,20 @@
|
||||
var request = require('request');
|
||||
|
||||
exports.importPublic = function(req, res) {
|
||||
var url = req.param('url');
|
||||
if(!url) {
|
||||
res.send(400, 'No URL parameter');
|
||||
}
|
||||
else if(url.indexOf("http://") === 0 || url.indexOf("https://") === 0) {
|
||||
var stream = request.get(url);
|
||||
stream.on('error', function(err) {
|
||||
res.send(400, err);
|
||||
});
|
||||
stream.on('response', function() {
|
||||
stream.pipe(res);
|
||||
});
|
||||
}
|
||||
else {
|
||||
res.send(400, 'Unknown protocol');
|
||||
}
|
||||
};
|
@ -25,7 +25,10 @@ app.get('/viewer', function (req, res) {
|
||||
res.render('viewer.html');
|
||||
});
|
||||
|
||||
app.post('/pdf', require('./pdf'));
|
||||
app.post('/pdfExport', require('./pdf').export);
|
||||
app.post('/sshPublish', require('./ssh').publish);
|
||||
app.post('/picasaImportImg', require('./picasa').importImg);
|
||||
app.get('/downloadImport', require('./download').importPublic);
|
||||
|
||||
// Error 404
|
||||
app.use(function(req, res, next) {
|
||||
|
@ -26,9 +26,10 @@ define([
|
||||
}
|
||||
title = url.substring(slashUrl + 1);
|
||||
$.ajax({
|
||||
url: constants.DOWNLOAD_PROXY_URL + "download?url=" + url,
|
||||
type: "GET",
|
||||
dataType: "text",
|
||||
url: constants.DOWNLOAD_IMPORT_URL + '?' + $.param({
|
||||
url: url
|
||||
}),
|
||||
dataType: 'text',
|
||||
timeout: constants.AJAX_TIMEOUT
|
||||
}).done(function(result) {
|
||||
content = result;
|
||||
|
Loading…
Reference in New Issue
Block a user