如何将旧上传迁移到 S3?

I now have all new uploads going straight to S3 but now I’d like to move all previous uploads to S3 as well. Is there a How To for this?

I searched the forums and found bits and pieces but not a step by step guide. I was unable to figure it out so far.

You should be able to use the uploads:migrate_to_s3 rake command. This would migrate your local files to the configured S3 bucket.

3 个赞

大家好,

我也遇到了同样的问题。不过我已经将 /uploads/ 文件夹迁移到了新的 S3 存储。有没有一种替代 uploads:migrate_to_s3 的方法,只重新链接文件而跳过实际上传?

我刚刚将实例从本地上传切换到了 S3 上传,但无论如何都无法让 S3 迁移工具正常工作。为了帮助其他可能查看此主题的人,我将在此总结所需的步骤。

  1. 在管理界面中启用 S3 上传,并设置所有必需的 S3 密钥和设置,以便新上传的文件发送至 S3。
  2. 在 app.yml 的 env 部分添加所需的 DISCOURSE_S3_ 环境变量。
    示例:
  DISCOURSE_S3_BUCKET: your-bucket-name
  DISCOURSE_S3_REGION: your-s3-bucket-region
  DISCOURSE_S3_ACCESS_KEY_ID: your-s3-access-key-id
  DISCOURSE_S3_SECRET_ACCESS_KEY: your-s3-secret-access-key
  1. 使用 ./launcher rebuild app 重建应用。
  2. 使用 ./launcher enter app 进入应用。
  3. 在 Docker 容器内运行 rails uploads:migrate_to_s3

我最初尝试使用 ./launcher run app rails uploads:migrate_to_s3 运行该命令,但它无法找到该任务。

4 个赞