Overview
TheFTPFileInfo type represents file and directory metadata returned by FTP server operations. It provides comprehensive information about files including timestamps, permissions, type information, and Unix-style file attributes.
Type Definition
Core Fields
The file creation time.This value is populated from the
create fact in MLST responses. It may be null if the server doesn’t provide creation time information.Example:The file’s last modification time.This is one of the most commonly available timestamps, populated from the
modify fact in MLST responses or from the MDTM command.Example:The file size in bytes.For directories, this is typically 0. For files, it represents the total size in bytes.Example:
Whether this entry represents a regular file.This is determined from the
type=file fact in MLST responses or inferred from SIZE command success.Example:Whether this entry represents a directory.This is determined from
type=dir, type=cdir, or type=pdir facts in MLST responses, or inferred when SIZE command fails with a directory error.Example:Whether this entry is a symbolic link.Defaults to
false. May be populated from server-specific MLST facts if the server provides symlink information.Example:FTP-Specific Fields
The FTP type from MLST responses.Common values include:
"file"- Regular file"dir"- Directory"cdir"- Current directory"pdir"- Parent directory
type fact from MLST responses.Example:FTP permissions string from the server.This represents permissions as defined in RFC 3659, section 7.5.5. The string contains permission codes like:
a- Append permissionc- Create permissiond- Delete permissione- Enter directory permissionf- Rename permissionl- List permissionp- Purge permissionr- Read permissionw- Write permission
The MIME media type of the file.Populated from the
media-type fact in MLST responses when the server provides this information.Example:The character encoding of the file.Populated from the
charset fact in MLST responses when available.Example:The language of the file content.Populated from the
lang fact in MLST responses when the server provides language information.Example:Unix-Style Fields
These fields are populated from Unix-specific facts in MLST responses (e.g.,unix.mode, unix.uid, unix.gid).
The Unix file mode/permissions as a numeric value.Parsed from the
unix.mode fact when provided by the server.Example:The Unix user ID of the file owner.Parsed from the
unix.uid fact when available.Example:The Unix group ID of the file.Parsed from the
unix.gid fact when available.Example:Device identifier.Defaults to
NaN. This field is included for compatibility with Node.js Stats objects but is rarely populated by FTP servers.Inode number.This field is included for compatibility with file system stat structures but is typically
null for FTP operations.Number of hard links.This field is included for compatibility but is typically
null for FTP operations.Device ID (if special file).This field is included for compatibility but is typically
null for FTP operations.Block size for file system I/O.This field is included for compatibility but is typically
null for FTP operations.Number of 512-byte blocks allocated.This field is included for compatibility but is typically
null for FTP operations.Last access time.This field is included for compatibility but is typically
null for FTP operations as most FTP servers don’t provide access time information.File birth/creation time.This field is included for compatibility but is typically
null. Use ctime instead for creation time from FTP servers.Special File Type Flags
Whether the file is a block device.Typically
null for FTP operations as FTP servers rarely expose device files.Whether the file is a character device.Typically
null for FTP operations.Whether the file is a FIFO (named pipe).Typically
null for FTP operations.Whether the file is a socket.Typically
null for FTP operations.Usage Examples
Check File Type
Display File Metadata
Filter Files by Size
Sort Files by Modification Time
Server Compatibility
The availability of specific fields depends on FTP server capabilities:
-
MLST/MLSD support: Servers that support these commands (RFC 3659) provide the most detailed metadata including
ftpType,ftpperms,mediaType, and Unix-style attributes. -
Limited support: Servers without MLST support will have fewer fields populated, typically just
size,mtime,isFile, andisDirectory. -
Field values: Many fields may be
nullif the server doesn’t provide that specific information.
See Also
- FTPClient.stat() - Retrieve file information
- FTPClient.extendedList() - Get directory listing with metadata
- ConnectionOptions - FTP connection configuration