Skip to content

Instantly share code, notes, and snippets.

@chmouel
Created December 6, 2010 17:38
Show Gist options
  • Save chmouel/730624 to your computer and use it in GitHub Desktop.
Save chmouel/730624 to your computer and use it in GitHub Desktop.
Transfer between cloud files account (via spooling localy on disks)
#!/usr/bin/python
# -*- encoding: utf-8 -*-
__author__ = "Chmouel Boudjnah <[email protected]>"
import cloudfiles
import tempfile
import os
FROM_AUTH_USER=""
FROM_AUTH_API_KEY=""
FROM_CONTAINER=""
TO_AUTH_USER=""
TO_AUTH_API_KEY=""
TO_CONTAINER=""
cnx_from = cloudfiles.get_connection(FROM_AUTH_USER, FROM_AUTH_API_KEY)
container_from = cnx_from.get_container(FROM_CONTAINER)
cnx_to = cloudfiles.get_connection(TO_AUTH_USER, TO_AUTH_API_KEY)
container_to = cnx_from.get_container(TO_CONTAINER)
for obj in container_from.get_objects():
tmp = tempfile.mktemp("-cfmigrate")
obj.save_to_filename(tmp)
print "Copying '%s': " % (obj.name),
write_obj = container_to.create_object(obj.name)
write_obj.write(open(tmp, 'r'))
print "done."
os.remove(tmp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment