# 如何在S3存储桶中查找未清除的孤立图像的所有变体？

**URL:** https://meta.discourse.org/t/how-to-find-all-variations-of-an-unpurged-orphaned-image-in-a-s3-bucket/263776
**Category:** Self-hosting
**Tags:** uploads, s3
**Created:** [2023 年5 月 4 日 07:22 UTC](https://meta.discourse.org/t/how-to-find-all-variations-of-an-unpurged-orphaned-image-in-a-s3-bucket/263776 "2023-05-04T07:22:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### 作者： ![markersocial](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markersocial/32/170136_2.png) [@markersocial](https://meta.discourse.org/u/markersocial)
#### 发布日期： [2023 年5 月 4 日 07:22 UTC](https://meta.discourse.org/t/how-to-find-all-variations-of-an-unpurged-orphaned-image-in-a-s3-bucket/263776/1 "2023-05-04T07:22:08Z")

</div>

我遇到了一个删除上传图片的问题。

上传似乎不存在于数据库中，至少根据我尝试过的搜索是这样的。它们是：

rails：

```plaintext
Upload.find_by_sha1('39b0c58d2d462e6c88d684344a8dd1f09da1ba47')

```

postgres：

```plaintext
select * from uploads where sha1 like '39b0c58d2d462e6c88d684344a8dd1f09da1ba47';

```

哈希值来自图片 URL（上面的哈希值仅为示例）。我通常可以用这些哈希值找到图片，并找到图片首次使用的地方。但这次我遇到了这种情况，上传似乎不存在，却又存在于存储桶中。

所以我不知道这是怎么发生的。

我检查了存储桶，发现 2 年前的图片文件就在那里。

所以我想我需要手动浏览存储桶来查找它们。我想知道，如果你有原始 URL 但没有数据库记录，是否有办法知道优化文件的路径？或者是否有其他查询可能会带来结果？

路径类似于：/original/2X/f/39b0c58d2d462e6c88d684344a8dd1f09da1ba47.jpg

我在 Scaleway 中看到存在 purge\_tombstone 策略并已启用。我在 Discourse 中将“purge deleted uploads grace period days”设置为 1 天。

---

<div class="post-metadata">

### 作者： ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### 发布日期： [2023 年6 月 8 日 06:01 UTC](https://meta.discourse.org/t/how-to-find-all-variations-of-an-unpurged-orphaned-image-in-a-s3-bucket/263776/2 "2023-06-08T06:01:03Z")

</div>

@markersocial 你找到解决办法了吗？🤞

---

<div class="post-metadata">

### 作者： ![markersocial](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markersocial/32/170136_2.png) [@markersocial](https://meta.discourse.org/u/markersocial)
#### 发布日期： [2023 年6 月 25 日 03:32 UTC](https://meta.discourse.org/t/how-to-find-all-variations-of-an-unpurged-orphaned-image-in-a-s3-bucket/263776/3 "2023-06-25T03:32:20Z")

</div>

您好 @JammyDodger - 遗憾的是不行，我唯一能做的就是手动从存储桶中删除单个图片，并希望没有优化过的版本。
