Skip to content

Commit

Permalink
Fixed a bug that shortens FTP upload data.
Browse files Browse the repository at this point in the history
  • Loading branch information
lovyan03 committed Feb 10, 2019
1 parent b4ca116 commit 4b4374c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions examples/SD-Updater/src/ESP32FtpServer.cpp
Expand Up @@ -713,7 +713,7 @@ boolean FtpServer::processCommand()
client.println( "501 No file name");
else if( makePath( path ))
{
file = SD.open(path, "r");
File file = SD.open(path, "r");
if(!file)
client.println( "450 Can't open " +String(parameters) );
else
Expand Down Expand Up @@ -784,12 +784,14 @@ boolean FtpServer::doStore()
{
if( data.connected() )
{
int16_t nb = data.readBytes((uint8_t*) buf, FTP_BUF_SIZE );
if( nb > 0 )
{
// Serial.println( millis() << " " << nb << endl;
file.write((uint8_t*) buf, nb );
bytesTransfered += nb;
for (;;) {
int16_t nb = data.readBytes((uint8_t*) buf, FTP_BUF_SIZE );
if( nb > 0 )
{
// Serial.println( millis() << " " << nb << endl;
file.write((uint8_t*) buf, nb );
bytesTransfered += nb;
} else break;
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/SD-Updater/src/ESP32FtpServer.h
Expand Up @@ -46,7 +46,7 @@
#define FTP_CMD_SIZE 255 + 8 // max size of a command
#define FTP_CWD_SIZE 255 + 8 // max size of a directory name
#define FTP_FIL_SIZE 255 // max size of a file name
#define FTP_BUF_SIZE 1024 //512 // size of file buffer for read/write
#define FTP_BUF_SIZE 512 // size of file buffer for read/write

class FtpServer
{
Expand Down

0 comments on commit 4b4374c

Please sign in to comment.