Beispiel #1
0
 c.on('ready', function() {
     c.put('README.md', 'README.md', function(err) {
         if (err) throw err;
         c.end();
         //c.close();
     });
 });
Beispiel #2
0
 c.on('ready', function() {
     c.put(outTextName, '/workspace/plugin/sql/raw/'+path.basename(outTextName), function(err) {
       if (err) throw err;
       console.log("end uploading txt file:"+file);
       c.end();
     });
 });
Beispiel #3
0
 final_arr.forEach(function(elem, index){
     var file_arr = elem.file.split("/");
     c.put(elem.file, '/htdocs/'+ username +'/'+ elem.directory +'/'+ file_arr[file_arr.length - 1], function(err) {
         if(index === final_arr.length - 1){
             c.end();
         }
     });
 });
  var upload = function() {
    var localFile = files.shift(),
        ftpFile   = ftpDir + localFile.substr(localDir.length);

    console.log(localFile, "...");
    if (fs.statSync(localFile).isDirectory()) {
      ftp.mkdir(ftpFile, true, cb);
    } else {
      ftp.put(localFile, ftpFile, cb);
    }
  },
 assets.forEach(function(file) {
     ftp.put(file.source, file.remotePath, function(err) {
         var timming = Date.now() - startTime;
         if (err) {
             console.log('error ', err);
             console.log('upload fail -', file.remotePath);
         } else {
             console.log('upload success -', file.remotePath, timming + 'ms');
         }
     });
 });
Beispiel #6
0
 client.mkdir(ftpDir, true, function (err) {
     if (err) {
         client.end();//断开连接
         cb(err);
     } else {
         log.info("put local" + path.join(self.baseDir, customerId + "_" + self.fileName) + "To remote" + path.join(ftpDir, self.fileName));
         client.put(path.join(self.baseDir, customerId + "_" + self.fileName), path.join(ftpDir, self.fileName), function (err) {
            client.end();
            cb(err);
         });
     }
 });
Beispiel #7
0
 it('should append data to existing file', function(done) {
   var fileSize = fs.statSync(__filename).size;
   client.put(__filename, '/uploads/' + basename, function(err) {
     common.should.not.exist(err);
     client.append(__filename, '/uploads/' + basename, function(err) {
       common.should.not.exist(err);
       var newSize = fs.statSync(uploadedFile).size;
       newSize.should.be.eql(fileSize * 2);
       done();
     });
   });
 });
Beispiel #8
0
    ftp.on("ready", function() {
      ftp.put(req.body.fullpath, req.body.shortname + ".mp4", function(err) {

        if (err) throw err;
        createAndFTPXmlFile(ftp, req.body.xmlFile, req.body.shortname + ".mp4", function() {
          ftp.end();
          updateStatusFile(req.body.statusFile, "FTP_COMPLETE", function() {
            res.writeHead(200, {"Content-Type": "text/plain"});
            res.end("FTP_COMPLETE");
          });
        });
      })
    });
Beispiel #9
0
 ftpClient.cwd(ftpWorkingDirectory, function (err) {
     if (err) {
         defer.reject(err);
     }
     else {
         ftpClient.put(fileSource, filename, function (err) {
             if (err) { defer.reject(err); }
             else {
                 ftpClient.end();
                 defer.resolve();
             }
         });
     }
 });
Beispiel #10
0
            ftpClient.on('ready', function() {
                ftpClient.put(the.path, conf.cftp.path+the.originalFilename, function(err) {
                    if (err) {
                        logger('main').error("file upload err by [%s]", the.path, JSON.stringify(err));                      
                    }

                    ftpClient.end();
                    ftpClient.destroy();

                    fs.exists(the.path, function (exists) {
                        if(exists){
                            logger('main').error('ftp suc and delete file [%s]', the.path);
                            fs.unlink(the.path);
                        }
                    });                             
                });
            });         
Beispiel #11
0
        var pop_list = (err) => {
            if (err) {

                //console.log('PUT error', err)
                sockets[data._sid].s.emit(data._scbk, {error: err})

            } else if (local_list.length) {

                toput = local_list.pop()
                path = toput.split('/')
                name = path.pop()
                path = path.join('/')

                if (current_path === path) {
                    //console.log('PUT', base_uri + '/' + toput, 'TO', name)
                    sockets[data._sid].s.emit(data._scbk, {inc: true})
                    c.put(base_uri + '/' + toput, name, pop_list)
                } else {
                    c.cwd('/' + data.rpath + path, (err) => {
                        if (err) {
                            c.mkdir('/' + data.rpath + path, true, (err) => {
                                if (!err) {
                                    //console.log('MKDIR', '/' + data.rpath + path)
                                    local_list.push(toput)
                                    pop_list()
                                } else {
                                    //console.log('MKDIR error', err)
                                    sockets[data._sid].s.emit(data._scbk, {error: err})
                                }
                            })
                        } else {
                            //console.log('MOVE', '/' + data.rpath + path)
                            current_path = path
                            local_list.push(toput)
                            pop_list()
                        }
                    })
                }


            } else {
                //console.log('ftp done')
                sockets[data._sid].s.emit(data._scbk, {success: true})
            }
        }
 function upload(origin, remote){
   grunt.verbose.write("starting file: ", origin);
   c.put(origin, remote, function(err){
     if(err) {
       throw({
         error: 'uploading file error',
         file: origin,
         e: err
       })
     }
     i++;
       grunt.verbose.write("uploaded: ", origin);
     if(i == files.length){
       c.end()
       grunt.log.ok("upload Done!")
       done()
     }
   })
 }
function uploadFile(startTime) {
  var file = __assets__.shift();
  // 没有文件就关闭连接
  if (!file) return client.end();
  // 开始上传
  client.put(file.source, file.remotePath, function(err) {
    // 本次上传耗时
    var timming = Date.now() - startTime;
    if (err) {
      console.log('error ', err);
      console.log('upload fail -', file.remotePath);
    } else {
      console.log('upload success -', file.remotePath, timming + 'ms');
    }
    // 每次上传之后检测下是否还有文件需要上传,如果没有就关闭连接
    if (__assets__.length === 0) {
      client.end();
    } else {
      uploadFile();
    }
  });
}
Beispiel #14
0
    ftpClient.mkdir( dir, true, function ( err ) {

      if ( err ) {
        grunt.log.error( err );
        ftpClient.end();
        done();
      }

      grunt.log.ok( filepath + '正在上传...' );

      ftpClient.put( fs.createReadStream( realeseFilepath ), filepath, function ( err ) {
        if ( err ) {
          grunt.log.error( err );
          ftpClient.end();
          done();
        }

        grunt.log.ok( filepath + ' 上传成功' );
        emitter.emit( 'success' );
      } );

    } );
Beispiel #15
0
c.on('ready', function() {
    c.put('feedbagaar.xml', 'feedbagaar.xml', function(err) {
        if (err) throw err;
        c.end();
    });
});
Beispiel #16
0
						http.get('http://files.jenjobs.com/files/resume/'+recordset[0].JsID+'/'+e.resume_file, function (body){
							c.put( body, 'jobseeker/resume/'+e.id+'/'+e.resume_file, function(err){
								console.log( 'jobseeker/resume/'+e.id+'/'+e.resume_file );
								console.log(err);
							});
						});
Beispiel #17
0
 function put_file(file, cb){ console.log(file); client.put(file, file, function(err){
   console.log('worked?');
 }); }
 self.put = function(local, remote, callback) {
     ftp.put(local, remote, callback)
 }
Beispiel #19
0
 function put_file(file, cb){
   console.log('uploading '.green + file);
   client.put(path.join(process.cwd(), 'public', file), file, cb);
 }
Beispiel #20
0
 ftp.on('ready', function () {
     ftp.put(localPath, remotePath, false, function (err) {
         ftp.end();
         callback(err);
     });
 });