aliyun / aliyun-oss-cpp-sdk

Aliyun OSS SDK for C++
Other
184 stars 88 forks source link

xp下上传文件报错 ValidateError Open upload file failed. #63

Open rfcff opened 4 years ago

rfcff commented 4 years ago

运行在xp sp3,oss-cpp-sdk静态编译,支持v140_xp方式编译,调用ResumableUploadObject时,报错如下: error_code:ValidateError, error_msg:Open upload file failed., request_id:, host: 在调用ResumableUploadObject之前检查过文件存在且对文件具备读写权限,win10下正常运行

rfcff commented 4 years ago

在ResumableUploadObject调用之前,执行 _access(file_path, 0); _access(file_path, 6); 这两个函数都正常 struct _stat buf = { 0 }; _stat(file_path, &buf); 出错,oss-cpp-sdk调用_stat64函数判断文件是否存在,在xp下执行一直失败

rfcff commented 4 years ago

经验证,发现vs2015调用_stat函数会失败(vs2015 sp3版本),参考https://stackoverflow.com/questions/32452777/visual-c-2015-express-stat-not-working-on-windows-xp 修改FileSystemUtils.cc函数AlibabaCloud::OSS::GetPathInfo,oss_wstat改用GetFileAttributesEx解决

rfcff commented 4 years ago

已经解决

rfcff commented 4 years ago

GetFileAttributesEx要处理FILETIME跟time_t之间的数据转换

ULARGE_INTEGER ui;
ui.LowPart = fileAttrData.ftCreationTime.dwLowDateTime;
ui.HighPart = fileAttrData.ftCreationTime.dwHighDateTime;
t = ((LONGLONG)(ui.QuadPart - 116444736000000000) / 10000000);