Question

I am using Rackspace to upload files in file container. Please suggest how to upload the file to Server and access the URL

Was it helpful?

Solution

Create an Valid Rackspace account Create a New container to save the files you need to keep

public bool CreateNewContainer(string strContainerName)
    {
        bool isSuccess = false;
        try
        {
            var cloudIdentity = new CloudIdentity() { APIKey = strAPIKey, Username = strUserName };
            var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
            ObjectStore createContainerResponse = cloudFilesProvider.CreateContainer(strContainerName);
            if (createContainerResponse == ObjectStore.ContainerCreated || createContainerResponse == ObjectStore.ContainerExists)
            {
                isSuccess = true;
            }
        }
        catch (Exception)
        { }
        return isSuccess;
    }

Then make the container publically available by setting CDN Enabled

var cloudIdentity = new CloudIdentity() { APIKey = strAPIKey, Username = strUserName };
var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
cloudFilesProvider.EnableCDNOnContainer(strContainerName, false);

Get the public URL of container

var cloudIdentity = new CloudIdentity() { APIKey = strAPIKey, Username = strUserName };
            var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
            ContainerCDN strCdnURL = cloudFilesProvider.GetContainerCDNHeader(strContainerName);
            string returnURL = strCdnURL.CDNUri

Then use this URL and file name of uploaded file to access the file publicly

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top