When you need to copy images from one Cloudinary account to another - for example when migrating or syncing between staging and production environments - there are two ways you can go about it.
You can use Cloudinary's auto-migration feature to dynamically copy used images. For more information see http://support.cloudinary.com/hc/en-us/articles/203752361-How-can-I-share-content-between-my-Production-and-Staging-environments-without-risking-my-live-app-.
Otherwise, if you want to pre-load the images, you can do that by writing and running a simple script that will copy the images. The script should iterate through your resources in the source account and upload them one by one to the destination account. Note that you can use concurrent uploads, but please limit concurrency to up to 50 parallel requests.
For the upload itself you can use the source image URL in the upload request, and you can also keep the same
public_id. For example in Rails:
Cloudinary::Uploader.upload('http://res.cloudinary.com/<your_source_cloud_name>/image/upload/image.jpg', :public_id => 'the_same_public_id')
What about videos?
The same principles are true for videos as well (both using auto-migration and the API).
How do you specify the destination cloud environment in this example ?
When you set-up the Cloudinary class, you need to define the cloud environment for that instance. any upload done after this point will be uploaded to the specified cloud.
For example, in PHP this is how the set-up looks like when using arguments.
Since the images are public, you don't need to connect the SDK to the source cloud - you just need to connect it to the target cloud.
Please sign in to leave a comment.