修复小文件上传问题
This commit is contained in:
@@ -846,7 +846,16 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
if (out_file) {
|
||||
out_file.write(reinterpret_cast<const char*>(file_data.data()),
|
||||
file_data.size());
|
||||
std::cout << "File saved: " << file_path << std::endl;
|
||||
// SendFileWebAuto reopens this path. Close first so data buffered by
|
||||
// ofstream (especially for small files) is visible to stat/libcurl.
|
||||
out_file.close();
|
||||
if (!out_file) {
|
||||
std::cerr << "Failed to write/close file: " << file_path << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
return;
|
||||
}
|
||||
std::cout << "File saved: " << file_path
|
||||
<< ", size=" << file_data.size() << " bytes" << std::endl;
|
||||
|
||||
//lnk20250805文件保存成功调用录波文件上送接口
|
||||
//update_qvvr_file_download(file_path, id);
|
||||
@@ -1171,7 +1180,18 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
if (out_file) {
|
||||
out_file.write(reinterpret_cast<const char*>(file_data.data()),
|
||||
file_data.size());
|
||||
std::cout << "File saved: " << file_path << std::endl;
|
||||
// The uploader reopens this path. Close first so buffered data is
|
||||
// visible to stat/libcurl; otherwise small files can upload as 0 bytes.
|
||||
out_file.close();
|
||||
if (!out_file) {
|
||||
std::cerr << "Failed to write/close file: " << file_path << std::endl;
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::INTERNAL_ERROR),
|
||||
id, 0, static_cast<int>(DeviceState::READING_FILEDATA));
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
return;
|
||||
}
|
||||
std::cout << "File saved: " << file_path
|
||||
<< ", size=" << file_data.size() << " bytes" << std::endl;
|
||||
|
||||
//调试用
|
||||
// 若是 .cfg,先查看并打印内容(限长)
|
||||
|
||||
Reference in New Issue
Block a user