Qiniu uploaded a picture with the same name, how to get a new link?

WBOY
Release: 2016-08-04 09:19:18
Original
1053 people have browsed it

Using Qiniu's private Bucket storage, PHP server, set insertOnly to 0, you can overwrite old pictures
Uploaded code:

<code>    
    $key="123.jpg";
    $policy=array('insertOnly'=> 0);
    $token = $this->auth->uploadToken($bucket,$key ,3600, $policy);
    // 构建 UploadManager 对象
    $uploadMgr = new UploadManager();
    $result = $uploadMgr -> putFile($token,$key,$path);
    return $result;
    </code>
Copy after login
Copy after login

After the upload is successful, this is how I get the image external link:

<code>    $baseUrl = $bucketDomain.'/'.$key;
    $authUrl = $this->auth->privateDownloadUrl($baseUrl);
    return $authUrl;</code>
Copy after login
Copy after login

Then return to the client tag and update the IMG's src using JS
But I found that the old image is still displayed. How can I solve this problem? Thank you very much!

Reply content:

Using Qiniu's private Bucket storage, PHP server, set insertOnly to 0, you can overwrite old pictures
Uploaded code:

<code>    
    $key="123.jpg";
    $policy=array('insertOnly'=> 0);
    $token = $this->auth->uploadToken($bucket,$key ,3600, $policy);
    // 构建 UploadManager 对象
    $uploadMgr = new UploadManager();
    $result = $uploadMgr -> putFile($token,$key,$path);
    return $result;
    </code>
Copy after login
Copy after login

After the upload is successful, this is how I get the image external link:

<code>    $baseUrl = $bucketDomain.'/'.$key;
    $authUrl = $this->auth->privateDownloadUrl($baseUrl);
    return $authUrl;</code>
Copy after login
Copy after login

Then return to the client tag and update the IMG's src using JS
But I found that the old image is still displayed. How can I solve this problem? Thank you very much!

Qiniu Cloud does caching, and the platform management provides a way to refresh the data of the specified URI to obtain the latest data.
I think you should generate a $key by yourself and add some time to generate random parameters (if you don’t specify the key, Qiniu will randomly hash the file name and store it)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template