1+ process . env . TMPDIR = 'tmp' ; // to avoid the EXDEV rename error, see http://stackoverflow.com/q/21071303/76173
2+
13var express = require ( 'express' ) ;
24var multipart = require ( 'connect-multiparty' ) ;
35var multipartMiddleware = multipart ( ) ;
4- var flow = require ( './flow-node.js' ) ( 'tmp/ ' ) ;
6+ var flow = require ( './flow-node.js' ) ( 'tmp' ) ;
57var app = express ( ) ;
68
79// Host most stuff in the public folder
810app . use ( express . static ( __dirname + '/public' ) ) ;
911app . use ( express . static ( __dirname + '/../../src' ) ) ;
1012
1113// Handle uploads through Flow.js
12- app . post ( '/upload' , multipartMiddleware , function ( req , res ) {
13- flow . post ( req , function ( status , filename , original_filename , identifier ) {
14- console . log ( 'POST' , status , original_filename , identifier ) ;
15- res . send ( 200 , {
16- // NOTE: Uncomment this funciton to enable cross-domain request.
17- //'Access-Control-Allow-Origin': '*'
14+ app . post ( '/upload' , multipartMiddleware , function ( req , res ) {
15+ flow . post ( req , function ( status , filename , original_filename , identifier ) {
16+ console . log ( 'POST' , status , original_filename , identifier ) ;
17+ res . send ( 200 , {
18+ // NOTE: Uncomment this funciton to enable cross-domain request.
19+ //'Access-Control-Allow-Origin': '*'
20+ } ) ;
1821 } ) ;
19- } ) ;
2022} ) ;
2123
2224// Handle cross-domain requests
@@ -31,15 +33,15 @@ app.post('/upload', multipartMiddleware, function(req, res){
3133*/
3234
3335// Handle status checks on chunks through Flow.js
34- app . get ( '/upload' , function ( req , res ) {
35- flow . get ( req , function ( status , filename , original_filename , identifier ) {
36- console . log ( 'GET' , status ) ;
37- res . send ( 200 , ( status == 'found' ? 200 : 404 ) ) ;
38- } ) ;
36+ app . get ( '/upload' , function ( req , res ) {
37+ flow . get ( req , function ( status , filename , original_filename , identifier ) {
38+ console . log ( 'GET' , status ) ;
39+ res . send ( 200 , ( status == 'found' ? 200 : 404 ) ) ;
40+ } ) ;
3941} ) ;
4042
41- app . get ( '/download/:identifier' , function ( req , res ) {
42- flow . write ( req . params . identifier , res ) ;
43+ app . get ( '/download/:identifier' , function ( req , res ) {
44+ flow . write ( req . params . identifier , res ) ;
4345} ) ;
4446
45- app . listen ( 3000 ) ;
47+ app . listen ( 3000 ) ;
0 commit comments