5 #include "FTPBasicAPI.h"
7 #include "FTPFileIterator.h"
8 #include "FTPSessionMgr.h"
12 namespace ftp_client {
20 template <
class ClientType>
25 FTPLogger::writeLog(LOG_DEBUG,
"FTPClient");
30 bool begin(IPAddress remote_addr,
const char *user =
"anonymous",
31 const char *password =
nullptr) {
32 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"begin");
34 this->password = password;
35 this->remote_addr = remote_addr;
36 return mgr.begin(remote_addr, this->port, user, password);
41 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"end");
47 bool autoClose =
false) {
49 snprintf(msg,
sizeof(msg),
"open: %s", filename);
50 FTPLogger::writeLog(LOG_INFO,
"FTPClient", msg);
57 return FTPFile(&api, filename, mode, autoClose);
62 bool mkdir(
const char *filepath) {
63 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"mkdir");
65 if (!api)
return false;
66 return api.mkdir(filepath);
71 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"remove");
73 if (!api)
return false;
74 return api.del(filepath);
78 bool rmdir(
const char *filepath) {
79 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"rmdir");
81 if (!api)
return false;
82 return api.rmd(filepath);
87 FTPLogger::writeLog(LOG_INFO,
"FTPClient",
"ls");
100 if (!api)
return false;
107 if (!api)
return false;
114 if (!api)
return false;
115 return api.type(str);
118 void setPort(
int port) {
124 return mgr.abort(op);
133 IPAddress remote_addr;
134 const char *userid =
nullptr;
135 const char *password =
nullptr;
137 bool cleanup_clients;
138 bool auto_close =
true;
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:70
bool abort(CurrentOperation op)
Abort the indicated operation (e.g., READ_OP, WRITE_OP, LS_OP.)
Definition: FTPClient.h:123
FTPFileIterator ls(const char *path, FileMode mode=WRITE_MODE)
Lists all file names in the specified directory.
Definition: FTPClient.h:86
bool ascii()
Switch to ascii mode.
Definition: FTPClient.h:105
FTPFile open(const char *filename, FileMode mode=READ_MODE, bool autoClose=false)
Open a file.
Definition: FTPClient.h:46
void end()
Close the sessions by calling QUIT or BYE.
Definition: FTPClient.h:40
FTPClient(int port=FTP_COMMAND_PORT)
Default constructor: Provide the client class as template argument e.g. FTPClient<WiFiClient> client;...
Definition: FTPClient.h:24
bool binary()
Switch to binary mode.
Definition: FTPClient.h:98
bool type(const char *str)
Binary or ascii with type command.
Definition: FTPClient.h:112
bool mkdir(const char *filepath)
Definition: FTPClient.h:62
bool begin(IPAddress remote_addr, const char *user="anonymous", const char *password=nullptr)
Opens the FTP connection.
Definition: FTPClient.h:30
bool rmdir(const char *filepath)
Removes a directory.
Definition: FTPClient.h:78
FTPSessionMgr< ClientType > & sessionMgr()
Provides access to the session manager.
Definition: FTPClient.h:128
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