# rake uploads:migrate\_to\_s3 失败，因为 DISCOURSE\_S3\_CDN\_URL 环境变量为空

**URL:** <https://meta.discourse.org/t/rake-uploads-migrate-to-s3-fails-because-discourse-s3-cdn-url-env-var-is-empty/129624>\
**Category:** Self-hosting\
**Created:** [2019年九月27日 00:39 UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-fails-because-discourse-s3-cdn-url-env-var-is-empty/129624 "2019-09-27T00:39:24Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![eatcodetravel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eatcodetravel/32/94385_2.png) [@eatcodetravel](https://meta.discourse.org/u/eatcodetravel)\
**Post date:** [2019年九月27日 01:32 UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-fails-because-discourse-s3-cdn-url-env-var-is-empty/129624/2 "2019-09-27T01:32:43Z")

</div>

我认为 Discourse 处理此问题的方式存在缺陷。当你将上传文件迁移到 S3 并设置 `DISCOURSE_S3_CDN_URL` 环境变量时，Discourse 也会尝试从 S3 获取资源。我曾不得不将上传文件和资源都迁移到 S3 加 CloudFront 才能使其正常工作，但这本不应是必需的，因为你只希望上传文件位于 S3 上。

你可以查看以下主题，看看是否有帮助。

> [@Defining DISCOURSE\_S3\_CDN\_URL links to assets in S3 CDN URL](https://meta.discourse.org/t/defining-discourse-s3-cdn-url-links-to-assets-in-s3-cdn-url/116798?u=eatcodetravel):
>
> I had this problem before and decided that I was crazy, confused, or the database on the site was suspect, but this is on a brand new site. Also, I was on Digital Ocean spaces, so I thought it might be a problem somehow. I’m trying again to figure out how to keep images on AWS S3 like I think the Big Boys do. Here’s what I have in the env section: DISCOURSE\_S3\_ACCESS\_KEY\_ID: 'key' DISCOURSE\_S3\_SECRET\_ACCESS\_KEY: 'lock' DISCOURSE\_BACKUP\_LOCATION: 's3' DISCOURSE\_S3\_BUCKET: 'lc-xyz' DI…

---

_[View the full topic](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-fails-because-discourse-s3-cdn-url-env-var-is-empty/129624)._
