【问题标题】:How to delete cloudinary image via PHP如何通过 PHP 删除云图像
【发布时间】:2021-11-28 05:21:53
【问题描述】:

我有一个 cloudinary_id 存储在 DB 中,并想从 Cloudinary 中删除此图像。 根据documentation,我在uploadApi 上调用desctroy 方法,其id 返回结果OK。但正如我所见,图像仍然可用。不明白。

这是代码:

$cloudinary = new Cloudinary($config);
return $cloudinary->uploadApi()->destroy($file_id);

此代码返回 Cloudinary\Api\ApiResponse #d6b5 结果 => "ok"

谁能告诉我这段代码有什么问题?

【问题讨论】:

  • 代码看起来很好,如果它返回了一个有效的结果,那么你的代码不是问题。在他们谈论 CDN 缓存的文档中,您是否尝试过传递 invalidate 参数以绕过 CDN 缓存,以及 resource_type 参数?

标签: php delete-file cloudinary destroy


【解决方案1】:

Cloudinary 使用 CDN 来确保媒体资源的快速交付。话虽如此,当通过 API 删除媒体时,您可能需要将可选参数“invalidation”设置为 true,以便在其 CDN 中使该对象无效。 以下是他们的 API 文档:

https://cloudinary.com/documentation/image_upload_api_reference#destroy_method https://cloudinary.com/documentation/admin_api#delete_resources

您可以使用上传 API 或管理 API。两者都达到相同的结果。

安东尼

【讨论】:

  • 谢谢。抱歉耽搁了。
猜你喜欢
  • 2015-09-23
  • 2018-06-17
  • 1970-01-01
  • 2019-05-25
  • 2020-09-11
  • 1970-01-01
  • 1970-01-01
  • 2020-10-22
  • 2020-10-13
相关资源
最近更新 更多