Skip to content
This repository

ftp.head method 

SaltwaterC edited this page · 2 revisions

Basic usage


ftp.head(options, callback);

  • options - the Options object
  • callback - the completion callback which has a couple of arguments:
    • error - an error, as indicated by the Error handling cases
    • result - the size of the remote file, or -1 if the SIZE command is not implemented


var ftp = require('ftp-get');
ftp.head('ftp://localhost/foo/bar.txt', function (error, size) {
    if (error) {
    } else {
        console.log('The remote file size is: ' + size); // the file size if everything is OK

If the SIZE command fails due to lack of RFC 3659 support aka the server returns the 500 error (command not implemented), then the size value is -1, unlike the rest of the 5xx status codes which are handled as errors. This allows you to make a proper decision about the SIZE return.

Something went wrong with that request. Please try again.