Thank you for visiting the Rackspace Community
The The Community is live! Post new content or topics so our teams can assist.

Please contact your support team if you have a question or need assistance for any Rackspace products, services, or articles.

.Net CreateObjectFromFile Returning Item Was Not Found Error

This question is answered.

I'm having issues trying to create files using the openstack.net API.  Below is the code I'm using:

CloudIdentity id = new CloudIdentity();
id.Username = "myusername";
id.APIKey = "myapikey";

CloudFilesProvider cfp = new CloudFilesProvider(id);
string sPath = @"C:\test.jpg";

cfp.CreateObjectFromFile("test", sPath, "test.jpg");

 

I am able to create containers and list those containers but every time I try to upload a file I get the error "The item was not found or does not exist."  The file definitely does exist on my local machine at the correct path and a container named "test" does exist already in my CloudFiles account and is listed when I call the ListContainers method.

I've also tried using the CreateObject method with a stream and get the same error.


I've looked at all the examples and they seem pretty straightforward so I'm not sure what I could be doing wrong.  Any help would be greatly appreciated.

Verified Answer
  • Since you did not specify a region in the CloudFilesProvider constructor, the provider is using the default region for your account. The default region may or may not match the region where you created the expected container. You should explicitly specify the region when creating the provider to match the region you are trying to upload your file to.

  • While I still am unclear how to use the constructor that includes the region for the CloudFilesProvider, it did lead me to discover that the CreateObjectFromFile method actually has a version that allows you to specify the region.  Using that version of the method and specifying the correct region solved my problem.

    Thank you for your help and for leading me in the right direction!

All Replies
  • Since you did not specify a region in the CloudFilesProvider constructor, the provider is using the default region for your account. The default region may or may not match the region where you created the expected container. You should explicitly specify the region when creating the provider to match the region you are trying to upload your file to.

  • You are correct that I'm not specifying the region in the CloudFilesProvider constructor.  I'm not sure how to do that.  I do see there is a constructor that allows me to specify the region, but it then also requires two more parameters and IdentityProvider and an iRestService.  I have no idea what those would be since I haven't seen them used in any examples.

  • While I still am unclear how to use the constructor that includes the region for the CloudFilesProvider, it did lead me to discover that the CreateObjectFromFile method actually has a version that allows you to specify the region.  Using that version of the method and specifying the correct region solved my problem.

    Thank you for your help and for leading me in the right direction!