简体   繁体   English

如何使用openstack.net在rackspace CloudFiles容器中创建Content-Type“application / directory”对象?

[英]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. 我正在尝试在Container中创建一个“目录”,只要我读取了rackspace api,创建它就应该创建一个0或1字节的对象,并将值“application / directory”赋给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. 必须使用适当的属性或方法修改“Content-Type”标头。 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": 尝试将值设置为“ContentType”而不是“name”:

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". 假设您创建了一个名为“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. 但是,如果你用Cyber​​Duck打开你的容器,你会发现一个名为User的文件夹,另一个叫做Foo的文件夹,里面是文件Bar.jpg。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用openstack.net从Rackspace上的CloudFiles获取jpg文件 - How to get jpg file from CloudFiles on Rackspace using openstack.net 如何使用OpenStack.NET创建新服务器 - How to create a new server using OpenStack.NET Openstack.Net SDK无法访问服务 - Openstack.Net SDK cannot access services 使用伦敦帐户通过openstack.net API云文件进行身份验证 - Authenticating with openstack.net API cloud files using London account ASP.NET MVC应用程序不输出内容类型标头 - ASP.NET MVC Application not outputting content-type header Openstack.Net SDK无法访问具有区域的服务 - Openstack.Net SDK cannot access service with region 无法使用 Headers[“Content-Type”] = “application/x-www-form-urlencoded” 在我的 WebClient UploadString 中编码我的 JSON 对象 - Unable to encode my JSON object inside my WebClient UploadString using Headers[“Content-Type”] = “application/x-www-form-urlencoded” 如何将Content-Type标头添加到.Net GET Web请求? - How to add the Content-Type header to a .Net GET web request? 如何在C#中检查内容类型/应用程序文本 - how to check content-type/application text in c# HttpWebRequest,如何使用 Application/JSON Content-Type 发送 POST 数据? - HttpWebRequest, How to Send POST Data with Application/JSON Content-Type?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM