When copying assets between Cloudinary environments—such as during migration or synchronization between staging and production—there are several methods you can use to accomplish this:
- You can leverage Cloudinary's auto-upload feature to dynamically copy active assets. For more information on this, please refer to this article: 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-.
- You can use the
clone
command in our CLI SDK to seamlessly copy assets between different product environments, preserving tags, context, and other metadata. For complete setup and usage instructions, refer to our CLI SDK documentation. - Alternatively, you can develop a custom solution using our APIs to copy assets between environments. Your script should iterate through resources in the source environment and upload them individually to the destination. To optimize performance, you can leverage concurrent uploads with up to 50 parallel requests. To retrieve the list of resources in the source environment you can use our Resources or Search methods and for the upload process, you can use the source asset URL in the request while maintaining the same
public_id
. Here is an example in Rails:Cloudinary::Uploader.upload('http://res.cloudinary.com/<your_source_cloud_name>/image/upload/image.jpg', :public_id => 'the_same_public_id')
Comments
4 comments
What about videos?
Thanks
Hi Willemijn,
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 ?
Hi Zeeshan,
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.