core/controller/controller.js
function (i, res, files, cb) {
        if (!files.length || files.length == 0) {
            cb(false)
        } else {
            if ( fs.existsSync(files[i].target) ) new _(files[i].target).rmSync();

            var sourceStream = fs.createReadStream(files[i].source);
            var destinationStream = fs.createWriteStream(files[i].target);

            sourceStream
                .pipe(destinationStream)
                .on('error', function () {
                    var err = 'Error on SuperController::copyFile(...): Not found ' + files[i].source + ' or ' + files[i].target;
                    cb(err)
                })
                .on('close', function () {

                    try {
                        fs.unlinkSync(files[i].source);
                        files.splice(i, 1);
                    } catch (err) {
                        cb(err)
                    }

                    movefiles(i, res, files, cb)
                })
        }
    }
function (i, res, files, cb) {
        if (!files.length || files.length == 0) {
            cb(false)
        } else {
            if ( fs.existsSync(files[i].target) ) new _(files[i].target).rmSync();

            var sourceStream = fs.createReadStream(files[i].source);
            var destinationStream = fs.createWriteStream(files[i].target);

            sourceStream
                .pipe(destinationStream)
                .on('error', function () {
                    var err = 'Error on SuperController::copyFile(...): Not found ' + files[i].source + ' or ' + files[i].target;
                    cb(err)
                })
                .on('close', function () {

                    try {
                        fs.unlinkSync(files[i].source);
                        files.splice(i, 1);
                    } catch (err) {
                        cb(err)
                    }

                    movefiles(i, res, files, cb)
                })
        }
    }
function ( i , res , files , cb ) { if ( ! files . length || files . length == 0 ) { cb ( false ) } else { if ( fs . existsSync ( files [ i ] . target ) ) new _ ( files [ i ] . target ) . rmSync ( ) ; var sourceStream = fs . createReadStream ( files [ i ] . source ) ; var destinationStream = fs . createWriteStream ( files [ i ] . target ) ; sourceStream . pipe ( destinationStream ) . on ( 'error' , function ( ) { var err = 'Error on SuperController::copyFile(...): Not found ' + files [ i ] . source + ' or ' + files [ i ] . target ; cb ( err ) } ) . on ( 'close' , function ( ) { try { fs . unlinkSync ( files [ i ] . source ) ; files . splice ( i , 1 ) ; } catch ( err ) { cb ( err ) } movefiles ( i , res , files , cb ) } ) } }
Move files to assets dir

@param {object} res
@param {collection} files

@callback cb
@param {object} [err]
Move files to assets dir