const ftp = require("basic-ftp");
async function getFileSize() {
const client = new ftp.Client();
try {
await client.access({
host: "ftp.example.com",
user: "your-username",
password: "your-password",
secure: true // 如果需要使用TLS/SSL连接,请设置为true
});
const fileInfo = await client.size("remote-file.txt");
console.log("File size:", fileInfo.size);
} catch (err) {
console.error(err);
} finally {
client.close();
}
}
getFileSize();