My putPolicy is:
coffeescope: CONFIG.qiniu.scope deadline: Math.floor(nextMonth.getTime() / 1000) endUser: "#{ appId }/#{ userId }" saveKey: '$(endUser)/$(x:targetId)/$(x:timestamp)' returnBody: '{\"key\":$(key)}' detectMime: 1
Android code, I use SDK 7.0.3:
javaUploadManager manager = new UploadManager(); Map<String, String> params = new HashMap<String, String>(); params.put("x:targetId", message.getRecipient()); params.put("x:timestamp", getTimestampString(new Date())); final UploadOptions opt = new UploadOptions(params, null, true, null, null); manager.put(filePath, null, token, new UpCompletionHandler() { @Override public void complete(String key, ResponseInfo info, JSONObject responseObject) { LogUtil.info(LogUtil.LOG_TAG_CHAT, "Upload file finished with key: " + key + ", info: " + info); } }, opt);
I can successfully upload image, but there is no key return, below is the log message:
Upload file finished with key: null, info: {ResponseInfo:com.qiniu.android.http.ResponseInfo@3e1293b1,status:200, reqId:wRIAAFC1CzaRn9cT, xlog:s.ph;s.ph;s.ph;PFDS;PFDS;PFDS:1;PTFDM;PFDT;s.gh;PFDS/613;PTFDM:1;PTFDS;rdb.g/no such key;DBD/404;DBG/404;v4.exist:1/Document not found;rs12_6.ins:1;qtbl.ins:2;mc.s;RS:3;rs.put:4;UP:14, xvia:null, host:upload.qiniu.com, ip:null, duration:0.034000 s, error:null}
The JavaScript SDK can get key, Where do I wrong?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
单从上传日志来看,上传是return了上传文件的key,不过获取返回的key需要通过
responseObject中把key字段解析出来