Skip to content

Commit

Permalink
fixed PCS API error: Can't get the error when upload failed
Browse files Browse the repository at this point in the history
  • Loading branch information
GangZhuo committed May 6, 2014
1 parent 34612e4 commit 78199d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion pcs/pcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ static PcsFileInfo *pcs_upload_form(Pcs handle, const char *path, PcsBool overwr
char *url, *html,
*dir = pcs_utils_basedir(path),
*filename = pcs_utils_filename(path);
cJSON *json;
cJSON *json, *item;
PcsFileInfo *meta;

url = pcs_http_build_url(pcs->http, URL_PCS_REST,
Expand Down Expand Up @@ -1349,6 +1349,18 @@ static PcsFileInfo *pcs_upload_form(Pcs handle, const char *path, PcsBool overwr
pcs_set_errmsg(handle, "Can't parse the response as json: %s", html);
return NULL;
}
//"{\"error_code\":31062,\"error_msg\":\"file name is invalid\",\"request_id\":3071564675}
item = cJSON_GetObjectItem(json, "error_code");
if (item) {
int error_code = item->valueint;
const char *error_msg = NULL;
item = cJSON_GetObjectItem(json, "error_msg");
if (item)
error_msg = item->valuestring;
pcs_set_errmsg(handle, "Can't upload file. error_code: %d, error_msg: %s, raw response: %s", error_code, error_msg, html);
cJSON_Delete(json);
return NULL;
}

meta = pcs_parse_fileinfo(json);
cJSON_Delete(json);
Expand Down
2 changes: 1 addition & 1 deletion pcs/pcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "pcs_slist.h"
#include "pcs_utils.h"

#define PCS_API_VERSION "v1.0.0"
#define PCS_API_VERSION "v1.0.1"

typedef enum PcsOption {
PCS_OPTION_END = 0,
Expand Down

0 comments on commit 78199d2

Please sign in to comment.