mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 11:53:48 +00:00
Fixed bug with spaces in filename
This commit is contained in:
@@ -58,7 +58,7 @@ CrealityPrint::CrealityPrint(DynamicPrintConfig* config) :
|
|||||||
m_ssl_revoke_best_effort(config->opt_bool("printhost_ssl_ignore_revoke"))
|
m_ssl_revoke_best_effort(config->opt_bool("printhost_ssl_ignore_revoke"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const char* CrealityPrint::get_name() const { return "CrealityPrint"; }
|
const char* CrealityPrint::get_name() const { return "Creality Print"; }
|
||||||
|
|
||||||
std::string CrealityPrint::get_host() const {
|
std::string CrealityPrint::get_host() const {
|
||||||
return m_host;
|
return m_host;
|
||||||
@@ -126,7 +126,7 @@ bool CrealityPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool res = true;
|
bool res = true;
|
||||||
auto url = make_url("upload/" + upload_filename.string());
|
auto url = make_url("upload/" + safe_filename(upload_filename.string()));
|
||||||
|
|
||||||
auto http = Http::post(url); // std::move(url));
|
auto http = Http::post(url); // std::move(url));
|
||||||
set_auth(http);
|
set_auth(http);
|
||||||
@@ -137,7 +137,7 @@ bool CrealityPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn,
|
|||||||
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: File uploaded: HTTP %2%: %3%") % name % status % body;
|
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: File uploaded: HTTP %2%: %3%") % name % status % body;
|
||||||
|
|
||||||
if (upload_data.post_action == PrintHostPostUploadAction::StartPrint) {
|
if (upload_data.post_action == PrintHostPostUploadAction::StartPrint) {
|
||||||
start_print(upload_filename.string());
|
start_print(safe_filename(upload_filename.string()));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on_error([&](std::string body, std::string error, unsigned status) {
|
.on_error([&](std::string body, std::string error, unsigned status) {
|
||||||
@@ -174,7 +174,15 @@ std::string CrealityPrint::make_url(const std::string &path) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CrealityPrint::start_print(const std::string &filename) const
|
std::string CrealityPrint::safe_filename(const std::string &filename) const
|
||||||
|
{
|
||||||
|
std::string safe_filename = filename;
|
||||||
|
std::replace(safe_filename.begin(), safe_filename.end(), ' ', '_');
|
||||||
|
|
||||||
|
return safe_filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CrealityPrint::start_print(const std::string &filename) const
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
std::string host = m_host;
|
std::string host = m_host;
|
||||||
@@ -219,10 +227,8 @@ std::string CrealityPrint::start_print(const std::string &filename) const
|
|||||||
ws.close(websocket::close_code::normal);
|
ws.close(websocket::close_code::normal);
|
||||||
} catch(std::exception const& e) {
|
} catch(std::exception const& e) {
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
return "false";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "true";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ private:
|
|||||||
bool m_ssl_revoke_best_effort;
|
bool m_ssl_revoke_best_effort;
|
||||||
|
|
||||||
std::string make_url(const std::string& path) const;
|
std::string make_url(const std::string& path) const;
|
||||||
std::string start_print(const std::string& path) const;
|
void start_print(const std::string& path) const;
|
||||||
|
std::string safe_filename(const std::string& filename) const;
|
||||||
};
|
};
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user