# 如何将文件从旧的上传方案（default/XXX）迁移到新的方案（default/original/{1,2}X）？

**URL:** <https://meta.discourse.org/t/how-can-i-migrate-files-from-the-old-upload-scheme-default-xxx-to-the-new-one-default-original-1-2-x/110813>\
**Category:** Support\
**Created:** [2019年三月6日 05:43 UTC](https://meta.discourse.org/t/how-can-i-migrate-files-from-the-old-upload-scheme-default-xxx-to-the-new-one-default-original-1-2-x/110813 "2019-03-06T05:43:02Z")\
**Posts on this page:** 1\
**Showing post:** 14

<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年三月17日 23:03 UTC](https://meta.discourse.org/t/how-can-i-migrate-files-from-the-old-upload-scheme-default-xxx-to-the-new-one-default-original-1-2-x/110813/14 "2019-03-17T23:03:19Z")

</div>

> [@zogstrip](#):
>
> If this returns `true` , then you have images using the old scheme.

But that’s true for new sites as well, because of stock images like:

```plaintext
=> [#<Upload:0x000055f79be02ac0
  id: -1,
  user_id: -1,
  original_filename: "d-logo-sketch.png",
  filesize: 14461,
  width: nil,
  height: nil,
  url: "/images/d-logo-sketch.png",
  created_at: Thu, 14 Mar 2019 12:13:08 UTC +00:00,
  updated_at: Thu, 14 Mar 2019 12:13:08 UTC +00:00,
  sha1: nil,
  origin: nil,
  retain_hours: nil,
  extension: "png",
  thumbnail_width: nil,
  thumbnail_height: nil,
  etag: nil>,

```

So I think that test should be:

```
Upload.where("url NOT LIKE '//%' AND url NOT LIKE '/uploads/default/original/_X/%' and id>0").exists?

```

Best I can tell, running `Jobs::MigrateUploadScheme.new.execute(nil)` won’t fix them. And that [keeps `rake uploads:migrate_from_s3` from running](https://meta.discourse.org/t/migrate-to-s3-for-digital-ocean-spaces-woes/109662/24).

---

_[View the full topic](https://meta.discourse.org/t/how-can-i-migrate-files-from-the-old-upload-scheme-default-xxx-to-the-new-one-default-original-1-2-x/110813)._
