Comparing version 0.4.3 to 0.4.4
@@ -481,4 +481,10 @@ /* | ||
var doPasv = function(err, res) { | ||
if (err || res.code !== 227) | ||
return callback(res.text); | ||
if (err || !res || res.code !== 227) { | ||
if (res && res.text) | ||
return callback(new Error(res.text)); | ||
else if (err) | ||
return callback(err); | ||
else | ||
return callback(new Error("Unknown error when trying to get into PASV mode")); | ||
} | ||
@@ -485,0 +491,0 @@ // Executes the next passive call, if there are any. |
{ | ||
"name": "jsftp", | ||
"id": "jsftp", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "A sane FTP client implementation for NodeJS", | ||
@@ -6,0 +6,0 @@ "keywords": [ "ftp", "protocol", "files", "server", "client", "async" ], |
@@ -37,2 +37,4 @@ jsftp [![Build Status](https://secure.travis-ci.org/sergi/jsftp.png)](http://travis-ci.org/sergi/jsftp) | ||
```javascript | ||
var Ftp = require("jsftp"); | ||
// Initialize some common variables | ||
@@ -44,41 +46,36 @@ var user = "johndoe"; | ||
host: "myhost.com", | ||
port: 21, // The port defaults to 21, but let's include it anyway. | ||
user: user, | ||
port: 3334, // The port defaults to 21 | ||
pass: pass | ||
}); | ||
// First, we authenticate the user | ||
ftp.auth(user, pass, function(err, res) { | ||
if (err) throw err; | ||
// Retrieve a file in the remote server. When the file has been retrieved, | ||
// the callback will be called with `data` being the Buffer with the | ||
// contents of the file. | ||
// Retrieve a file in the remote server. When the file has been retrieved, | ||
// the callback will be called with `data` being the Buffer with the | ||
// contents of the file. | ||
// `ftp.get` is a convenience method. In this case, it hides the actual | ||
// complexity of setting up passive mode and retrieving files. | ||
ftp.get("/folder/file.ext", function(err, data) { | ||
if (err) | ||
console.error(err); | ||
// This is a convenience method that hides the actual complexity of setting | ||
// up passive mode and retrieving files. | ||
// Do something with the buffer | ||
doSomething(data); | ||
ftp.get("/folder/file.ext", function(err, data) { | ||
if (err) throw err; | ||
// We can use raw FTP commands directly as well. In this case we use FTP | ||
// 'QUIT' method, which accepts no parameters and returns the farewell | ||
// message from the server | ||
ftp.raw.quit(function(err, res) { | ||
if (err) | ||
console.error(err); | ||
// Do something with the buffer | ||
doSomething(data); | ||
// We can use raw FTP commands directly as well. In this case we use FTP | ||
// 'QUIT' method, which accepts no parameters and returns the farewell | ||
// message from the server | ||
ftp.raw.quit(function(err, res) { | ||
if (err) throw err; | ||
console.log("FTP session finalized! See you soon!"); | ||
}); | ||
console.log("FTP session finalized! See you soon!"); | ||
}); | ||
}); | ||
// The following code assumes that you have authenticated the user, just like | ||
// I did in the code above. | ||
// Create a directory | ||
ftp.raw.mkd("/example_dir", function(err, data) { | ||
if (err) | ||
throw err; | ||
console.error(err); | ||
@@ -91,3 +88,3 @@ console.log(data.text); | ||
if (err) | ||
throw err; | ||
console.error(err); | ||
@@ -98,3 +95,3 @@ console.log(data.text); | ||
You can find more usage examples in the unit tests for it. This documentation | ||
You can find more usage examples in the [unit tests](https://github.com/sergi/jsftp/blob/master/test/jsftp_test.js). This documentation | ||
will grow as jsftp evolves. | ||
@@ -178,5 +175,5 @@ | ||
To run the tests from the command line: | ||
To run the tests: | ||
node test/jsftp_test.js | ||
npm test | ||
@@ -183,0 +180,0 @@ Please note that for now the unit tests require python because the FTP server |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
405296
1641
2
184