HockeyApp 自己上传错误日志的坑
Posted 长空小鹰
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HockeyApp 自己上传错误日志的坑相关的知识,希望对你有一定的参考价值。
0 HockeyApp对于上传格式有严格要求,只要不符合规定,不好意思,没有错误信息,只有404。如果是404,可以考虑其实是格式错误。
1 HockeyApp只接受multipart上传,可以使用curl的form post。也可以使用mine,具体查看文档。
2 log,description,attachment0这三个字段必须以文件形式上传,也就是说,字段头中必须有filename="xxxx",否则404
附带自己写的c++用curl上传的线程函数范例,经测试可用:
struct SendErrorReportThreadData { ErrorReport data; std::string url; std::string content; };void SendErrorReportThread(SendErrorReportThreadData* data) { CURL *curl; CURLcode res; struct curl_httppost *formpost = NULL; struct curl_httppost *lastptr = NULL; struct curl_slist *headerlist = NULL; static const char buf[] = "Expect:"; curl = curl_easy_init(); if(curl) { curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "log", CURLFORM_BUFFER, "log.txt", CURLFORM_BUFFERPTR, data->content.c_str(), CURLFORM_BUFFERLENGTH, data->content.size(), CURLFORM_END); if(!data->data.message.empty()) { curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "description", CURLFORM_BUFFER, "description.txt", CURLFORM_BUFFERPTR, data->data.message.c_str(), CURLFORM_BUFFERLENGTH, data->data.message.size(), CURLFORM_END); } if(!data->data.log.empty()) { curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "attachment0", CURLFORM_BUFFER, "attachment0.txt", CURLFORM_BUFFERPTR, data->data.log.c_str(), CURLFORM_BUFFERLENGTH, data->data.log.size(), CURLFORM_END); } headerlist = curl_slist_append(headerlist, buf); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); /* what URL that receives this POST */ curl_easy_setopt(curl, CURLOPT_URL, data->url.c_str()); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); res = curl_easy_perform(curl); /* Check for errors */ if(res != CURLE_OK) { CCLOG("OSUtility::SendErrorReport ----> curl_easy_perform() failed: %s ", curl_easy_strerror(res)); } else { long http_code = 0; curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &http_code); CCLOG("OSUtility::SendErrorReport ----> successfully send one report. HTTP code:%ld", http_code); } /* always cleanup */ curl_easy_cleanup(curl); /* then cleanup the formpost chain */ curl_formfree(formpost); /* free slist */ curl_slist_free_all(headerlist); } delete data; }
以上是关于HockeyApp 自己上传错误日志的坑的主要内容,如果未能解决你的问题,请参考以下文章
powershell Powershell脚本将UWP .zip包上传到hockeyapp进行部署