根据该错误,您是否可能在创建对象时发送“if-none-match”标头?设置该标头后,如果您尝试上载容器中已存在的文件,则会引发该错误。我不相信您可以将该标头用于版本控制,因为检查基于名称,而不是正在上载的文件哈希值。只是一个猜测。 :-)
下面是一个控制台应用程序,它在上传新版本之前上传文件两次,以证明这应该有效。
using System; using System.Collections.Generic; using net.openstack.Core.Domain; using net.openstack.Core.Providers; using net.openstack.Providers.Rackspace; namespace CloudFilesVersioning { class Program { static void Main(string[] args) { var identityUrl = new Uri("{identity-url}"); var identity = new CloudIdentityWithProject { Username = "{user}", ProjectName = "{project-name}", Password = "{password}" }; const string region = "RegionOne"; var identityProvider = new OpenStackIdentityProvider(identityUrl, identity); var filesProvider = new CloudFilesProvider(null, identityProvider); // Create versions container const string versionContainerName = "mycontainer-versions"; filesProvider.CreateContainer(versionContainerName, region: region); // Create main container const string containerName = "mycontainer"; var headers = new Dictionary<string, string> { {"X-Versions-Location", versionContainerName} }; filesProvider.CreateContainer(containerName, headers, region); // Upload the initial file filesProvider.CreateObjectFromFile(containerName, @"C:\thing-v1.txt", "thing.txt", region: region); // Upload the same file again, this should not create a new version filesProvider.CreateObjectFromFile(containerName, @"C:\thing-v1.txt", "thing.txt", region: region); // Upload a new version of the file filesProvider.CreateObjectFromFile(containerName, @"C:\thing-v2.txt", "thing.txt", region: region); } } }