Closed gfosco closed 13 years ago
Hi @gfosco!
If your problem is only to set default directory for uploads, you can specify it in the formaline configuration object :
{
..
uploadRootDir : yourdir
..
}
If you have other questions or I haven't understood what it is your issue, ( like bad formaline char escaping ), let me know !
P.S. the message that you get is only a warning, you can also disable logging for not seeing it ! .
Hi.. I did set the directory in the config object, and that wasn't helping. I'm currently making a few changes in lib/formaline.js.
Right now it makes the directory, and there's a 0 byte file for the upload, and it crashes for not finding ".req.debug.log" in the created directory.
Turning off file logging to remove that issue.
Sorry I have accidentally closed issue ;)
This is from log4js and the console... you can see it keeps adding slashes...
←[32m[2011-09-15 13:48:15.289] [INFO] console
In order to make this work on windows, I did the following:
However I didn't understand how you have created the uploadRootDir. Could you publish a gist? It could help me to understand better this Windows issue!
Well, I replaced the getSessionId with a function that just returns a static string. Does that make sense?
The upload dir is going to be the same all the time, so I will ensure it is created before the node server is deployed.
It make sense! You could also return a static string form getSessionID. However, as you can see in the docs ( upload section ), in this case formaline replaces files that already exist in the directory ( same resulting sha1 hash for filename ) .
function recognizeActionPost( req, res ) {
var d = new Date();
log.info( 'Got recognition request \r\n\r' );
var url_parts = url.parse( req.url, true );
var query = url_parts.query;
var config = {
logging : 'debug:on,1:on,2:on,3:on,console:on,file:on,record:off',
uploadRootDir : 'C:\\optimo\\UploadedImages',
mkDirSync : false,
requestTimeOut : 40000, // 40 secs
resumeRequestOnError : true,
holdFilesExtensions : true,
checkContentLength : false,
uploadThreshold : 3949000,
removeIncompleteFiles : true,
emitProgress : false,
emitFileProgress : false,
sha1sum : false,
getSessionID : function ( req ) {
return 'node-session-x';
},
listeners : {
'message' : function( json ){
// json : { type : '..', isupload : true/false , msg : '..' }
log.info( 'message: ' + util.inspect( json ) );
},
'error' : function( json ){ // json : { type : '', isupload : true/false , msg : '..', fatal : true }
log.info( 'error: ' + util.inspect( json ) );
},
'abort' : function( json ) {
log.info('abort: ' + util.inspect( json ) );
},
'timeout' : function( json ) {
log.info('timeout: ' + util.inspect( json ) );
},
'loadstart' : function( json ){
log.info('load start: ' + util.inspect( json ) );
},
'fileprogress' : function( json, payload ) {
log.info('file progress: ' + util.inspect( json ) );
},
'progress' : function( json ) {
log.info('progress: ' + util.inspect( json ) );
},
'load' : function( json ){
log.info('load: ' + util.inspect( json ) );
},
'loadend' : function( json, resp, cback ) {
log.debug( 'loadend: ' + util.inspect( json ) );
if ( json.files && json.files[ 0 ].value && json.files[ 0 ].value[ 0 ].path ) {
//next steps on file.
} else {
//send back error
cback();
}
}
}
};
var form = new formaline( config );
form.parse( req, res, function() { log.info( 'Finished form processing.' ); } );
}
However, What about writing a gist of your original code that failed with formaline?
@gfosco : I think it cuold be better to publish a gist, not the entire code here ( and also bad formatted :) .
However, as you have noticed, formaline doesn't make correct use of the directory char delimiter for Windows ( '\' instead of '/' ). I can't say now if other problems will arise ( for Windows ) apart this one.
I have to do some tests, then I'll return to you for updates . ;)
It seems like the directory stuff is hard-coded to support only *nix systems. I am attempting this with Windows and Node 0.5.6, getting warning/error that the upload path doesn't exist. The message shows the back-slashes escaped.