How can I get a new link when Qiniu uploads an image with the same name?

Source: Internet
Author: User
The private Bucket storage of Qiniu is used. on The PHP server, set insertOnly to 0 to overwrite the code uploaded from the old image: {code ...} after the upload is successful, I obtain the image external link as follows: {code ...} then return the tag to the client, and update the src of IMG with JS, but still... the private Bucket storage of Qiniu is used. on The PHP server, set insertOnly to 0 to overwrite the old image.
Uploaded code:

$ Key = "123.jpg"; $ policy = array ('insertonly '=> 0); $ token = $ this-> auth-> uploadToken ($ bucket, $ key, 3600, $ policy); // Construct the UploadManager object $ uploadMgr = new UploadManager (); $ result = $ uploadMgr-> putFile ($ token, $ key, $ path); return $ result;

After the upload is successful, I obtain the image outer link as follows:

    $baseUrl = $bucketDomain.'/'.$key;    $authUrl = $this->auth->privateDownloadUrl($baseUrl);    return $authUrl;

Then return the tag to the client, and update the src of IMG with JS.
However, the old images are still displayed. I am very grateful for how to solve this problem!

Reply content:

The private Bucket storage of Qiniu is used. on The PHP server, set insertOnly to 0 to overwrite the old image.
Uploaded code:

$ Key = "123.jpg"; $ policy = array ('insertonly '=> 0); $ token = $ this-> auth-> uploadToken ($ bucket, $ key, 3600, $ policy); // Construct the UploadManager object $ uploadMgr = new UploadManager (); $ result = $ uploadMgr-> putFile ($ token, $ key, $ path); return $ result;

After the upload is successful, I obtain the image outer link as follows:

    $baseUrl = $bucketDomain.'/'.$key;    $authUrl = $this->auth->privateDownloadUrl($baseUrl);    return $authUrl;

Then return the tag to the client, and update the src of IMG with JS.
However, the old images are still displayed. I am very grateful for how to solve this problem!

Qiniu Cloud caches data, and platform management provides a data refresh specified uri to obtain the latest data.
I think you should generate$keyGenerate random parameters with some time (if no key is specified, Qiniu will randomly hash file name storage)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.