简体   繁体   中英

How to create an object with Content-Type “application/directory” inside a rackspace CloudFiles Container with openstack.net?

I am trying to create a "directory" inside a Container, as long as I have read the rackspace api, to create it you should create a 0 or 1 byte object and assign the value "application/directory" to the Content-Type.

I tried this:

var cloudFilesProvider = new CloudFilesProvider(_cloudIdentity);
                Dictionary<string, string> dicHeaders = new Dictionary<string, string>();
                dicHeaders.Add("name", "application/directory");
                MemoryStream ms = new MemoryStream(1);                
                cloudFilesProvider.CreateObject(ContainerName, ms, DirectoryPath, 0, dicHeaders);

But I get an exception

The 'Content-Type' header must be modified using the appropriate property or method. Parameter name: name

Do anyone have created these kind of object?

I think you are adding the wrong header. Instead of "name", try setting the value to "ContentType":

dicHeaders.Add("ContentType", "application/directory");

Update: I think that in general directories are not needed. Let's say you create an object, called "User/Foo/Bar.jpg". If you look in your container through the website, you will the image with this name. However, if you open your container with CyberDuck, you will find a folder User, inside it another one called Foo, and inside it will be the file Bar.jpg.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM