gpt4 book ai didi

javascript - 替换 Cloudinary 上的图像

转载 作者:行者123 更新时间:2023-12-03 12:22:45 24 4
gpt4 key购买 nike

我正在尝试使用其 public_id 替换 cloudinary 上的图像。所以,我使用时间戳、public_id 和覆盖进行签名。我已将覆盖值设置为“true”。下面我附上了正在传递的参数的屏幕截图。图片已成功上传,但版本标签不同,但原始图片未替换。

奇怪的是,更改后的图像在第一次上传时成功替换了原始图像,但对该图像的任何进一步上传都不起作用。因此,上传成功,但上传时使用了不同的版本标签。

http://cloudinary.com/documentation/upload_images#renaming_images我已使用上面链接中给出的覆盖选项来替换原始图像。

我等了很长一段时间(至少半小时),认为更改可能需要时间才能反射(reflect),但它保持不变。

对这里可能出现的问题有什么见解吗?

var newForm = new FormData();
newForm.append('timestamp',ts);
newForm.append('api_key', $rootScope.CLOUDINARY_CONFIG.api_key);
newForm.append('signature', signature);
newForm.append('public_id', scope.model.public_id);
newForm.append('overwrite', true);
newForm.append('file', canvasImage);

$http.post($rootScope.CLOUDINARY_CONFIG.upload_url, newForm, {
transformRequest: angular.identity,
file : canvasImage,
headers: {'X-Requested-With': 'XMLHttpRequest','Content-Type': undefined}
})
.success(function(data){
// success
})
.error(function(err){
// log error
console.log('fail');
});

enter image description here

最佳答案

如果您指的是交付相同的第一个上传的图像而不是更新的图像,那么您似乎获得了该图像的 CDN 缓存版本。您应该在 URL 中包含版本组件(正确的版本值包含在上传响应中,或者使用已包含版本组件的上传调用返回的 URL),或者您可以上传时将 invalidate 参数设置为 true 以使图像无效。请注意,失效可能需要一个小时才能通过 CDN 完全传播。这里还有更多 information

关于javascript - 替换 Cloudinary 上的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24362073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com