# \`rake uploads:migrate\_to\_s3\` 需要一些优化

**URL:** https://meta.discourse.org/t/rake-uploads-migrate-to-s3-needs-some-love/109497
**Category:** Bug
**Created:** [2019年二月18日 22:55 UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-needs-some-love/109497 "2019-02-18T22:55:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2019年二月18日 22:55 UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-needs-some-love/109497/1 "2019-02-18T22:55:26Z")

</div>

The `uploads:migrate_to_s3` rake task could use some attention.

There is no `GlobalSetting.use_s3?`, but a `GlobalSetting.use_s3` and the ENV variables have changed, as `DISCOURSE_S3_BUCKET` has been replaced by `DISCOURSE_S3_UPLOAD_BUCKET`.

> <https://github.com/discourse/discourse/blob/main/lib/tasks/uploads.rake#L231>

I’m only a little bit sure that I know how to fix this, and I think that it’s fresh in @gerhard’s mind. 🙂

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2019年二月18日 23:59 UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-needs-some-love/109497/2 "2019-02-18T23:59:18Z")

</div>

> [@pfaffman](#):
>
> There is no `GlobalSetting.use_s3?` , but a `GlobalSetting.use_s3`

```plaintext
[1] pry(main)> GlobalSetting.use_s3
NoMethodError: undefined method `use_s3' for GlobalSetting:Class
Did you mean? use_s3?

```

> [@pfaffman](#):
>
> the ENV variables have changed, as `DISCOURSE_S3_BUCKET` has been replaced by `DISCOURSE_S3_UPLOAD_BUCKET` .

> <https://github.com/discourse/discourse/blob/c08b2ddecfaed0f0ab3e3b30743b55d5f5230fb2/config/discourse_defaults.conf#L170>

The code in the rake task is still valid from what I can tell. Did you run into any specific problems that made you bring up the issues above?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2019年二月19日 00:00 UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-needs-some-love/109497/3 "2019-02-19T00:00:39Z")

</div>

> [@tgxworld](#):
>
> The code in the rake task is still valid from what I can tell. Did you run into any specific problems that made you bring up the issues above?

uh. Hmm. I’ll try again.

I think I’m confused because it seems like it should be able to read those variables from `SiteSettings` and I don’t understand how the backup and upload buckets get defined from just the S3 bucket.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2019年二月19日 00:17 UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-needs-some-love/109497/4 "2019-02-19T00:17:55Z")

</div>

For `GlobalSettings`,

> <https://github.com/discourse/discourse/blob/4f5aebc33812a56c34e553bd18c0cfe7ddc4c3f4/config/discourse_defaults.conf#L7-L13>

Only `SiteSettings` that are marked `shadowed_by_global` can be configured via the env. In this case, `s3_upload_bucket` isn’t.

> [@pfaffman](#):
>
> I don’t understand how the backup and upload buckets get defined from just the S3 bucket.

> <https://github.com/discourse/discourse/blob/4f5aebc33812a56c34e553bd18c0cfe7ddc4c3f4/app/models/site_setting.rb#L129-L131>

Closing this as this isn’t a bug.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2019年二月19日 00:17 UTC](https://meta.discourse.org/t/rake-uploads-migrate-to-s3-needs-some-love/109497/5 "2019-02-19T00:17:59Z")

</div>


