Search code examples
c#rackspacerackspace-cloudfiles

Error uploading attachment : The item was not found or does not exist


I m using RackSpace to upload email attachments. This is how I m trying to upload it to RackSpace Cloud:

//Skipped Authentication Setup
string containerName = ConfigurationManager.AppSettings["ContainerName"];

using (var stream = new MemoryStream())
{
    StreamWriter memoryWriter = new StreamWriter(stream);
    memoryWriter.Write(file);
    stream.Position = 0;
    stream.Seek(0, 0);
    cloudFilesProvider.CreateObject(containerName, stream, fileName);
}

var header = cloudFilesProvider.GetContainerCDNHeader(containerName, "ORD");
string Url = header.CDNSslUri + "/" + fileName;

This code uploads file of size 0 into Cloud and on reaching to header variable, it throws error:

The item was not found or does not exist

Any help would be appreciated.


Solution

  • Can you verify that your container is CDN enabled? If it is not, when you HEAD the CDN management URL for the the container, it will return a HTTP 404. I suspect this is what is happening.

    I am not sure what libraries you are using, but you can find info on how to CDN enable a container here:

    https://developer.rackspace.com/docs/cloud-files/v1/developer-guide/#cdn-enabling-the-container-and-setting-a-ttl