5

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

Liya S
  • 439
  • 4
  • 13

1 Answers1

5

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

Prem Singh
  • 1,035
  • 3
  • 13
  • 31