cdnrackspace-cloudrackspace-cloudfiles

Uncompress file on Rackspace cloud files container for CDN


I have created a Rackspace account earlier today for CDN to serve my Opencart images from Rackspace.

I have created a container where i will upload over 500,000 images, but prefer to upload them as a compressed file, feels more flexible.

If i upload all the images in a compressed file how do i extract the file when it is in the container? and what compression type files would work?


Solution

  • The answer may depend on how you are attempting to upload your file/files. Since this was not specified, I will answer your question using the CLI from a *nix environment.

    Answer to your question (using curl)

    Using curl, you can upload a compressed file and have it extracted using the extract-archive feature.

    $ tar cf archive.tar directory_to_be_archived
    $ curl -i -XPUT -H'x-auth-token: AUTH_TOKEN' https://storage101.iad3.clouddrive.com/v1/MossoCloudFS_aaa-aaa-aaa-aaa?extract-archive=tar -T ./archive.tar
    

    You can find the documentation for this feature here: http://docs.rackspace.com/files/api/v1/cf-devguide/content/Extract_Archive-d1e2338.html

    Recommended solution (using Swiftly)

    Uploading and extracting that many objects using the above method might take a long time to complete. Additionally if there is a network interruption during that time, you will have to start over from the beginning.

    I would recommend instead using a tool like Swiftly, which will allow you to concurrently upload your files. This way if there is a problem during the upload, you don't have to re-upload objects that have alreaady been successfully uploaded.

    An example of how to do this is as follows:

    $ swiftly --auth-url="https://identity.api.rackspacecloud.com/v2.0" \
    --auth-user="{username}" --auth-key="{api_key}" --region="DFW" \
    --concurrency=10 put container_name -i images/
    

    If there is a network interruption while uploading, or you have to stop/restart uploading your files, you can add the "--different" option after the 'put' in the above command. This will tell Swiftly to HEAD the object first and only upload if the time or size of the local file does not match its corresponding object, skipping objects that have already been uploaded.

    Swiftly can be found on github here: https://github.com/gholt/swiftly

    There are other clients that possibly do the same things, but I know Swiftly works, so I recommend it.