简体   繁体   English

如何将 ActiveStorage blob 从生产 S3 存储桶复制/镜像到本地开发?

[英]How to replicate/mirror ActiveStorage blobs from production S3 bucket to development Local?

I have a production system using an Amazon S3 bucket for storing ActiveStorage blobs (Rails 6.0.3).我有一个使用 Amazon S3 存储桶来存储 ActiveStorage blob (Rails 6.0.3) 的生产系统。

For development, I use the Local service because I don't want to inadvertently mess with the production data.对于开发,我使用本地服务,因为我不想无意中弄乱生产数据。

What is the best way to replicate/mirror/sync the production bucket locally so I can use it just a as scratch for development and testing?在本地复制/镜像/同步生产存储桶的最佳方法是什么,以便我可以将它用作开发和测试的临时?

I have tried replicating the production database locally and copying the bucket directly to the Local service directory but ActiveStorage doesn't see the blobs with the right keys.我尝试在本地复制生产数据库并将存储桶直接复制到本地服务目录,但 ActiveStorage 没有看到带有正确密钥的 blob。 (Not sure why?) (不知道为什么?)

I have also seen some examples of the Mirror service being used between cloud services or from Local to cloud services, but not from cloud services to Local.我还看到了一些在云服务之间或从本地到云服务使用镜像服务的例子,但没有从云服务到本地。

Local storage is organized in subdirectories本地存储组织在子目录中

$ tree storage
storage
├── ZD # first 2 char
│   └── ou # third and fourth car
│       └── ZDouA9nEzJjWAx71Cmb3WVeY

while S3 stores file in flat format (no under sub-directories).而 S3 以平面格式存储文件(没有子目录下)。 The above file will be store as a direct file under the bucket上述文件将作为直接文件存储在bucket下

ZDouA9nEzJjWAx71Cmb3WVeY

I don't know it applies to Rails (and which version).我不知道它适用于 Rails(以及哪个版本)。 But I had succeeded in transferring development storage files to S3 using the above concept (Spree 4 - which uses rails framework 6).但是我已经成功地使用上述概念(Spree 4 - 它使用 rails 框架 6)将开发存储文件传输到 S3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM