Write some more upload data
| 352 | |
| 353 | // Write some more upload data |
| 354 | void FtpResponder::DoUpload() noexcept |
| 355 | { |
| 356 | // Write incoming data to the file |
| 357 | const uint8_t *_ecv_array buffer; |
| 358 | size_t len; |
| 359 | if (dataSocket->ReadBuffer(buffer, len)) |
| 360 | { |
| 361 | if (reprap.Debug(Module::Webserver)) |
| 362 | { |
| 363 | GetPlatform().MessageF(UsbMessage, "Writing %u bytes of upload data\n", len); |
| 364 | } |
| 365 | |
| 366 | dataSocket->Taken(len); |
| 367 | if (!fileBeingUploaded.Write(buffer, len)) |
| 368 | { |
| 369 | uploadError = true; |
| 370 | GetPlatform().Message(ErrorMessage, "FTP: could not write upload data\n"); |
| 371 | CancelUpload(); |
| 372 | |
| 373 | responderState = ResponderState::pasvTransferComplete; |
| 374 | return; |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | // Upload has finished if the connection is closed |
| 379 | if (!dataSocket->CanRead()) |
| 380 | { |
| 381 | dataSocket = nullptr; |
| 382 | responderState = ResponderState::pasvTransferComplete; |
| 383 | |
| 384 | FinishUpload(0, 0, false, 0); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | // Try to read some data from the main FTP port and return true |
| 389 | // if anything significant could be done |