How can I migrate CarrierWave files to a new storage mechanism?

前端 未结 4 834
南旧
南旧 2021-02-06 02:31

I have a Ruby on Rails site with models using CarrierWave for file handling, currently using local storage. I want to start using cloud storage and I need to migrate existing lo

4条回答
  •  星月不相逢
    2021-02-06 03:15

    I have migrated the Carrier wave files to Amazon s3 with s3cmd and it works.

    Here are the steps to follow:

    1. Change the storage kind of the uploader to fog.
    2. Create a bucket on Amazon s3 if you already dont have one.
    3. Install s3cmd on the remote server sudo apt-get install s3cmd
    4. Configure s3cmd s3cmd --configure. You would need to enter public and secret key here, provided by Amazon.
    5. Sync the files by this command s3cmd sync /path_to_your_files ://bucket_name/
    6. Set this flag --acl-public to upload the file as public and avoid permission issues.
    7. Restart your server

    Notes:

    sync will not duplicate your records. It will first check if the file is present on remote server or not.

提交回复
热议问题