【问题标题】:How to make images not duplicate with Cloudinary Image Upload using node npm如何使用 node npm 使图像不与 Cloudinary Image Upload 重复
【发布时间】:2017-08-02 04:03:39
【问题描述】:

如何覆盖我上传到 cloudinary 的图像,这样我就不会重复并且拥有多个完全相同的图像?

【问题讨论】:

    标签: cloudinary


    【解决方案1】:

    假设您的帐户中有一张名为“sample_image”的图片,并且您想上传另一张具有相同名称的图片,您只需将public_id 设置为“sample_image”并添加overwrite 参数即可上传。 此外,您可能希望从 CDN 中清除旧图像以确保您提供的是最新版本,因此还要在上传调用中将 invalidate 标志设置为 true

    cloudinary.uploader.upload('my_image.jpg', function(result) { console.log(result) }, 
                           { public_id: "sample_image", overwrite:true, invalidate,true });
    

    【讨论】:

    • 知道如何快速擦除我的整个帐户的所有 public_id 吗?
    • 您可以使用 Admin API 删除资源。您可以全部删除,也可以按特定条件删除。 cloudinary.com/documentation/admin_api#delete_resources
    • 让客户端代码负责防止重复真的很可悲。有云内置图像比较会很好(不仅仅是返回像 md5 和 phash 这样的描述)。
    • @SerG Cloudinary 通过自动将 public_id 设置为资源的 etag 具有此选项,从而防止任何重复。
    猜你喜欢
    • 2019-04-20
    • 2020-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-18
    • 1970-01-01
    • 1970-01-01
    • 2012-03-22
    相关资源
    最近更新 更多