# 从旧帖子下载远程图片？

**URL:** <https://meta.discourse.org/t/download-remote-images-from-older-posts/146134>\
**Category:** Support\
**Created:** [2020年三月30日 12:37 UTC](https://meta.discourse.org/t/download-remote-images-from-older-posts/146134 "2020-03-30T12:37:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2020年三月30日 12:37 UTC](https://meta.discourse.org/t/download-remote-images-from-older-posts/146134/1 "2020-03-30T12:37:43Z")

</div>

你好。

我之前导入过一个 phpBB 论坛。  
我想我在导入时没有设置下载远程图片的选项，因为旧帖子中嵌入了带有外部链接的图片。

我想下载旧帖子中的所有这些图片。

有相关的命令可以执行吗？我有大约 150,000 篇帖子需要解析。

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2020年三月31日 06:58 UTC](https://meta.discourse.org/t/download-remote-images-from-older-posts/146134/2 "2020-03-31T06:58:29Z")

</div>

这里有什么建议吗 @vinothkannans 或 @gerhard？

---

<div class="post-metadata">

**Author:** ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)\
**Post date:** [2020年三月31日 09:28 UTC](https://meta.discourse.org/t/download-remote-images-from-older-posts/146134/3 "2020-03-31T09:28:55Z")

</div>

- 启用“将远程图片下载到本地”站点设置。
- 将“下载远程图片的最大天数”站点设置的值设为 3650（即 10 年）。
- 将“重烤旧帖子数量”站点设置的值增加至 300。若需将其设置为超过 300，还需调整全局速率限制器设置“[`max_old_rebakes_per_15_minutes`](https://github.com/discourse/discourse/blob/243284f998e213034f9f0c6b228f97f7c9834fdd/config/discourse_defaults.conf#L235)”。
- 并在 Rails 控制台中将旧帖子的“`baked_version`

---

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2020年四月19日 20:45 UTC](https://meta.discourse.org/t/download-remote-images-from-older-posts/146134/4 "2020-04-19T20:45:05Z")

</div>

快速提问：为什么需要做这个操作：

> ```ruby
> Post.update_all(baked_version: nil)
> 
> ```

如果我将 **下载远程图片的最大天数** 设置为 20 年呢？

---

<div class="post-metadata">

**Author:** ![Overgrow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overgrow/32/478189_2.png) [@Overgrow](https://meta.discourse.org/u/Overgrow)\
**Post date:** [2020年四月19日 21:40 UTC](https://meta.discourse.org/t/download-remote-images-from-older-posts/146134/5 "2020-04-19T21:40:26Z")

</div>

这将在所有帖子中触发缓慢的重渲染，因为系统会检测到需要将帖子重渲染为新版本。

---

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2020年四月19日 22:22 UTC](https://meta.discourse.org/t/download-remote-images-from-older-posts/146134/6 "2020-04-19T22:22:30Z")

</div>

但我看到了一篇 2010 年的帖子，其中包含一张远程图片。我除了修改 **下载远程图片的最大天数** 设置外，没有做任何其他更改，结果几分钟后该远程图片就被自动下载了。

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/b/eb2a018d0c26bd5d0ccc60aedfbaae0c49d82f33.png)  
系统确实编辑了这篇非常古老的帖子，以便下载远程图片。

编辑：过了一夜，其他旧图片也被自动下载了，这很好，但我完全不明白 `update_all(baked_version: nil)` 这部分是做什么的。

---

<div class="post-metadata">

**Author:** ![Wildweasel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wildweasel/32/128234_2.png) [@Wildweasel](https://meta.discourse.org/u/Wildweasel)\
**Post date:** [2020年五月15日 09:02 UTC](https://meta.discourse.org/t/download-remote-images-from-older-posts/146134/7 "2020-05-15T09:02:33Z")

</div>

您好，  
我已应用该脚本，但不确定其对性能和服务器机房是否有重大影响？

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2020年六月14日 09:04 UTC](https://meta.discourse.org/t/download-remote-images-from-older-posts/146134/8 "2020-06-14T09:04:41Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
