5#include "FTPBasicAPI.h"
7#include "FTPFileIterator.h"
8#include "FTPSessionMgr.h"
20template <
class ClientType>
24 FTPClient(
int port = FTP_COMMAND_PORT,
bool useType =
false) {
25 FTPLogger::writeLog(LOG_DEBUG,
"FTPClient");
32 use_type_command = useType;
36 bool begin(IPAddress remote_addr,
const char *user =
"anonymous",
37 const char *password =
nullptr) {
38 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"begin");
40 this->password = password;
41 this->remote_addr = remote_addr;
42 return mgr.begin(remote_addr, this->port, user, password);
47 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"end");
53 bool autoClose =
false) {
55 snprintf(msg,
sizeof(msg),
"open: %s", filename);
56 FTPLogger::writeLog(LOG_INFO,
"FTPClient", msg);
63 return FTPFile(&api, filename, mode, autoClose);
68 bool mkdir(
const char *filepath) {
69 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"mkdir");
71 if (!api)
return false;
72 return api.mkdir(filepath);
77 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"remove");
79 if (!api)
return false;
80 return api.del(filepath);
84 bool rmdir(
const char *filepath) {
85 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"rmdir");
87 if (!api)
return false;
88 return api.rmd(filepath);
93 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"ls");
106 if (!api)
return false;
107 api.setUseTypeCommand(use_type_command);
114 if (!api)
return false;
115 api.setUseTypeCommand(use_type_command);
122 if (!api)
return false;
123 return api.type(str);
126 void setPort(
int port) {
132 return mgr.abort(op);
141 IPAddress remote_addr;
142 const char *userid =
nullptr;
143 const char *password =
nullptr;
145 bool cleanup_clients;
146 bool auto_close =
true;
147 bool use_type_command =
false;
FTPBasicAPI Implementation of Low Level FTP protocol. In order to simplify the logic we always use Pa...
Definition FTPBasicAPI.h:17
FTPClient Basic FTP access class which supports directory operations and the opening of files.
Definition FTPClient.h:21
bool remove(const char *filepath)
Delete the file.
Definition FTPClient.h:76
bool abort(CurrentOperation op)
Abort the indicated operation (e.g., READ_OP, WRITE_OP, LS_OP.)
Definition FTPClient.h:131
void setUseTypeCommand(bool useType)
if set to true the BIN and ASCII command are executed as type I or A
Definition FTPClient.h:31
FTPClient(int port=FTP_COMMAND_PORT, bool useType=false)
Default constructor: Provide the client class as template argument e.g. FTPClient<WiFiClient> client;...
Definition FTPClient.h:24
FTPFileIterator ls(const char *path, FileMode mode=WRITE_MODE)
Lists all file names in the specified directory.
Definition FTPClient.h:92
bool ascii()
Switch to ascii mode.
Definition FTPClient.h:112
FTPFile open(const char *filename, FileMode mode=READ_MODE, bool autoClose=false)
Open a file.
Definition FTPClient.h:52
void end()
Close the sessions by calling QUIT or BYE.
Definition FTPClient.h:46
bool binary()
Switch to binary mode.
Definition FTPClient.h:104
bool type(const char *str)
Binary or ascii with type command.
Definition FTPClient.h:120
FTPSessionMgr< ClientType > & sessionMgr()
Provides access to the session manager.
Definition FTPClient.h:136
bool mkdir(const char *filepath)
Definition FTPClient.h:68
bool begin(IPAddress remote_addr, const char *user="anonymous", const char *password=nullptr)
Opens the FTP connection.
Definition FTPClient.h:36
bool rmdir(const char *filepath)
Removes a directory.
Definition FTPClient.h:84
FTPFile A single file which supports read and write operations. This class is implemented as an Ardui...
Definition FTPFile.h:16
FTPFileIterator The file name iterator can be used to list all available files and directories....
Definition FTPFileIterator.h:18
FTPSessionMgr This class manages multiple FTP sessions, allowing for concurrent operations and sessio...
Definition FTPSessionMgr.h:17