Fix PrusaLink upload when PUT is used (#5843)

(SoftFever/OrcaSlicer#5840) Fix PrusaLink upload when PUT is used
This commit is contained in:
Noisyfox 2024-06-25 00:48:38 +08:00 committed by GitHub
parent 34ad17bcd2
commit 76fc7e6d21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -116,7 +116,7 @@ struct Http::priv
std::string headers;
size_t limit;
bool cancel;
std::unique_ptr<fs::ifstream> putFile;
std::unique_ptr<form_file> putFile;
std::thread io_thread;
Http::CompleteFn completefn;
@ -381,7 +381,7 @@ void Http::priv::set_put_body(const fs::path &path)
boost::system::error_code ec;
boost::uintmax_t filesize = file_size(path, ec);
if (!ec) {
putFile = std::make_unique<fs::ifstream>(path, std::ios_base::binary |std::ios_base::in);
putFile = std::make_unique<form_file>(form_file{{path, std::ios_base::binary | std::ios_base::in}, 0, 0});
::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
::curl_easy_setopt(curl, CURLOPT_READDATA, (void *) (putFile.get()));
::curl_easy_setopt(curl, CURLOPT_INFILESIZE, filesize);