From 099bd1900672291ed256b54818cb3160ce0c5f7a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 1 May 2025 23:23:10 +0200 Subject: Support FTPS uploads. --- src/lib/curl_uploader.cc | 4 ++++ src/lib/types.cc | 30 +++++++++++++++++------------- src/lib/types.h | 3 ++- src/lib/upload_job.cc | 1 + src/wx/upload_destination_dialog.cc | 1 + 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/lib/curl_uploader.cc b/src/lib/curl_uploader.cc index d36909a2e..522ce5f65 100644 --- a/src/lib/curl_uploader.cc +++ b/src/lib/curl_uploader.cc @@ -103,6 +103,10 @@ CurlUploader::upload_file(boost::filesystem::path from, boost::filesystem::path curl_easy_setopt(_curl, CURLOPT_RESUME_FROM_LARGE, static_cast(-1)); curl_easy_setopt(_curl, CURLOPT_INFILESIZE_LARGE, boost::filesystem::file_size(from)); + if (_destination.protocol == FileTransferProtocol::FTPS) { + curl_easy_setopt(_curl, CURLOPT_USE_SSL, CURLUSESSL_ALL); + } + dcp::File file(from, "rb"); if (!file) { throw NetworkError(String::compose(_("Could not open %1 to send"), from)); diff --git a/src/lib/types.cc b/src/lib/types.cc index 0be90e5c7..e544f896d 100644 --- a/src/lib/types.cc +++ b/src/lib/types.cc @@ -117,11 +117,13 @@ reel_type_to_string(ReelType type) FileTransferProtocol file_transfer_protocol_from_string(string s) { - if (s == "scp") { - return FileTransferProtocol::SCP; - } else if (s == "ftp") { - return FileTransferProtocol::FTP; - } + if (s == "scp") { + return FileTransferProtocol::SCP; + } else if (s == "ftp") { + return FileTransferProtocol::FTP; + } else if (s == "ftps") { + return FileTransferProtocol::FTPS; + } DCPOMATIC_ASSERT(false); return FileTransferProtocol::SCP; @@ -131,14 +133,16 @@ file_transfer_protocol_from_string(string s) string file_transfer_protocol_to_string(FileTransferProtocol p) { - switch (p) { - case FileTransferProtocol::SCP: - return "scp"; - case FileTransferProtocol::FTP: - return "ftp"; - default: - DCPOMATIC_ASSERT(false); - } + switch (p) { + case FileTransferProtocol::SCP: + return "scp"; + case FileTransferProtocol::FTP: + return "ftp"; + case FileTransferProtocol::FTPS: + return "ftps"; + default: + DCPOMATIC_ASSERT(false); + } return ""; } diff --git a/src/lib/types.h b/src/lib/types.h index 9cc20d8b4..eea63e119 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -142,7 +142,8 @@ struct CPLSummary enum class FileTransferProtocol { SCP, - FTP + FTP, + FTPS }; diff --git a/src/lib/upload_job.cc b/src/lib/upload_job.cc index 2acc97320..4ca5a64eb 100644 --- a/src/lib/upload_job.cc +++ b/src/lib/upload_job.cc @@ -86,6 +86,7 @@ UploadJob::run() uploader.reset(new SCPUploader(_destination, bind(&UploadJob::set_status, this, _1), bind(&UploadJob::set_progress, this, _1, false))); break; case FileTransferProtocol::FTP: + case FileTransferProtocol::FTPS: uploader.reset(new CurlUploader(_destination, bind(&UploadJob::set_status, this, _1), bind(&UploadJob::set_progress, this, _1, false))); break; } diff --git a/src/wx/upload_destination_dialog.cc b/src/wx/upload_destination_dialog.cc index a32055c60..2bac4ea72 100644 --- a/src/wx/upload_destination_dialog.cc +++ b/src/wx/upload_destination_dialog.cc @@ -58,6 +58,7 @@ UploadDestinationDialog::UploadDestinationDialog(wxWindow* parent) _protocol->add_entry(_("SCP"), file_transfer_protocol_to_string(FileTransferProtocol::SCP)); _protocol->add_entry(_("FTP"), file_transfer_protocol_to_string(FileTransferProtocol::FTP)); + _protocol->add_entry(_("FTPS"), file_transfer_protocol_to_string(FileTransferProtocol::FTPS)); _protocol->bind(&UploadDestinationDialog::protocol_changed, this); _limit_connections->bind(&UploadDestinationDialog::limit_connections_changed, this); -- cgit v1.2.3