I want to get the token of the file that can be updated by setting the key to bucket: key, but return the token obtained by using the following code to the android client (client android, server PHP, the client first obtains the uptoken from the server and then uploads a specific file with the token.), new... I want to get the token of the file that can be updated by setting the key to bucket: key, but return the token obtained by using the following code to the android client (client android, server PHP, the client first obtains the up token from the server and then uploads a specific file with the token.) The newly uploaded image does not overwrite the source image. Where is the problem?
Php:
$bucket = "phpsdk"; $accessKey = QINIU_ACCESS_KEY; $secretKey = QINIU_SECRET_KEY; Qiniu_SetKeys($accessKey, $secretKey); $key=$this->input->post("file_key"); if($key!=""){ $putPolicy = new Qiniu_RS_PutPolicy($bucket.":".$key); $upToken = $putPolicy->Token(null); echo $upToken; }
Android:
// TmpFile is the uploaded file, key is the file name to be updated, and qiniuUploadToken is the obtained upload credential UploadManager uploadManager = new UploadManager (); uploadManager. put (tmpFile, key, qiniuUploadToken, new UpCompletionHandler () {@ Override public void complete (String key, ResponseInfo info, JSONObject response) {try {if (response! = Null) {final String actualKey = response. getString ("key"); Log. d (TAG, "get server side key =" + actualKey) ;}, new Response. errorListener () {@ Override public void onErrorResponse (VolleyError error) {}}); MessageQueue. getInstance (). addToRequestQueue (jsonObjReq, TAG);} else {Log. e (TAG, "Error from Qiniu:" + info. error) ;}} catch (JSONException e) {e. printStackTrace () ;}}, new UploadOptions (null, null, false, new UpProgressHandler () {public void progress (String key, double percent) {Log. I ("qiniu", key + "(progress):" + percent) ;}, new UpCancellationSignal () {public boolean isCancelled () {return isQiniuCancelled ;}}));
Reply content:
I want to get the token of the file that can be updated by setting the key to bucket: key, but return the token obtained by using the following code to the android client (client android, server PHP, the client first obtains the up token from the server and then uploads a specific file with the token.) The newly uploaded image does not overwrite the source image. Where is the problem?
Php:
$bucket = "phpsdk"; $accessKey = QINIU_ACCESS_KEY; $secretKey = QINIU_SECRET_KEY; Qiniu_SetKeys($accessKey, $secretKey); $key=$this->input->post("file_key"); if($key!=""){ $putPolicy = new Qiniu_RS_PutPolicy($bucket.":".$key); $upToken = $putPolicy->Token(null); echo $upToken; }
Android:
// TmpFile is the uploaded file, key is the file name to be updated, and qiniuUploadToken is the obtained upload credential UploadManager uploadManager = new UploadManager (); uploadManager. put (tmpFile, key, qiniuUploadToken, new UpCompletionHandler () {@ Override public void complete (String key, ResponseInfo info, JSONObject response) {try {if (response! = Null) {final String actualKey = response. getString ("key"); Log. d (TAG, "get server side key =" + actualKey) ;}, new Response. errorListener () {@ Override public void onErrorResponse (VolleyError error) {}}); MessageQueue. getInstance (). addToRequestQueue (jsonObjReq, TAG);} else {Log. e (TAG, "Error from Qiniu:" + info. error) ;}} catch (JSONException e) {e. printStackTrace () ;}}, new UploadOptions (null, null, false, new UpProgressHandler () {public void progress (String key, double percent) {Log. I ("qiniu", key + "(progress):" + percent) ;}, new UpCancellationSignal () {public boolean isCancelled () {return isQiniuCancelled ;}}));
This may be caused by the cdn cache to overwrite the uploaded files and the accessed files are still old resources. Can you use the url? V = 20150309 access the resource. If the access is the latest resource, it indicates that the resource overwrite is successful. Generally, the cache refresh time of the resource is 10 minutes, and the whole network refresh is 24 hours, if you have high requirements on real-time resource update, You can refresh the resource url in the advanced settings of Space settings, you can also use the resource url and query parameters to access the resource.