# 迁移到 S3 脚本在图片已存在于 S3 时出现 URL 处理错误

**URL:** <https://meta.discourse.org/t/url-processing-error-in-migrate-to-s3-script-when-images-are-already-present-on-s3/103224>\
**Category:** Bug\
**Created:** [2018年十二月1日 02:29 UTC](https://meta.discourse.org/t/url-processing-error-in-migrate-to-s3-script-when-images-are-already-present-on-s3/103224 "2018-12-01T02:29:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zyniker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zyniker/32/120004_2.png) [@Zyniker](https://meta.discourse.org/u/Zyniker)\
**Post date:** [2018年十二月1日 02:29 UTC](https://meta.discourse.org/t/url-processing-error-in-migrate-to-s3-script-when-images-are-already-present-on-s3/103224/1 "2018-12-01T02:29:32Z")

</div>

## Issue

If images are uploaded between `enable_s3_uploads` being configured and enabled and the `rake uploads:migrate_to_s3` task being run, the URLs of the aforementioned images (i.e., those that were uploaded in the space between the configuration change and the rake task being run) will be incorrectly processed.

## Steps to Replicate

1. Configure and enable `enable_s3_uploads`.
2. Upload an image somewhere on the forum.
3. Run `rake uploads:migrate_to_s3`.

The image uploaded in step 2 will not load properly due to having an incorrect URL.

## Proposed Solution

Perhaps the `migrate_to_s3` script should check for images that are _already present on S3_.

(Granted, this is very clearly a type of ‘user error’ as the forum should probably be locked when migrating.)

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [2019年一月28日 10:02 UTC](https://meta.discourse.org/t/url-processing-error-in-migrate-to-s3-script-when-images-are-already-present-on-s3/103224/5 "2019-01-28T10:02:34Z")

</div>

The `uploads:migrate_to_s3` rake task has been re-worked and is now much _much_ faster and works properly with images already on S3.

You should try it if you still need it 😉

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [2019年一月29日 17:00 UTC](https://meta.discourse.org/t/url-processing-error-in-migrate-to-s3-script-when-images-are-already-present-on-s3/103224/6 "2019-01-29T17:00:02Z")

</div>

This topic was automatically closed after 30 hours. New replies are no longer allowed.
