C# 对于含有中文名字的文件上传到swift不成功!!!! SwiftC#URL对象String 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我测试通过的代码(windows gbk,可以参考python-swiftclient --debug -v的等同curl命令输出):csharp-swiftusing System;using System.IO;using System.Collections.Generic;using System.Text;using OpenStack.Swift;namespace SwiftClientCSharp{ class Program { public static void Main(string[] args) { SwiftClient sc = new SwiftClient(); sc.DisableSSLCertificateValidation(); string url="https://192.168.179.61:8080/auth/v1.0"; string user="system:root"; string key="testpass"; Dictionary<string,string> headers = new Dictionary<string, string>(); Dictionary<string,string> query = new Dictionary<string, string>(); AuthResponse ar = sc.GetAuth(url,user,key,headers,query,false); string token = ar.Headers["x-auth-token"]; string xurl = ar.Headers["x-storage-url"]; string srcContainerName = "CSharp中文名"; string srcObjectName = "CSharp中文名.txt"; UTF8Encoding utf8 = new UTF8Encoding(); byte[] utf8bytes = utf8.GetBytes(srcContainerName); StringBuilder sb = new StringBuilder(); foreach (byte tmp in utf8bytes) { sb.AppendFormat("%{0:X2}",tmp); } string containerName = sb.ToString(); sb.Clear(); utf8bytes = utf8.GetBytes(srcObjectName); foreach(byte tmp in utf8bytes) { sb.AppendFormat("%{0:X2}",tmp); } string objectName = sb.ToString(); sb.Clear(); Stream fstream = new FileStream(srcObjectName,FileMode.Open); ContainerResponse cr = sc.PutContainer(xurl,token,containerName,headers,query); ObjectResponse or = sc.PutObject(xurl,token,containerName,objectName,fstream,headers,query); fstream.Close(); ContainerResponse cr2 = sc.GetContainer(xurl,token,containerName,headers,query,true); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); } }} 某局点桌面云退出不能重连的问题 云计算下的“运维改革”:可视化 2014软件谷“云计算&大数据技术峰会”在南京召开 如何限制容器的内存大小 问:对于根设备,使用本地实例存储与使用 Amazon Elastic Block Storage (Amazon EBS) 有什么区别? 经典java、.net、php、网页平面视频教程DVD免费申领 Spark 定时任务!!在线等。 我用了定时器然后报错了 有关使用spark进行数据处理的问题 无法使用CloudFront 想问下桌面虚拟化怎么分配硬件资源? nova-volume和swift的区别 如何在没网环境下搭建swift
csharp-swiftusing System;
using System.IO;
using System.Collections.Generic;
using System.Text;using OpenStack.Swift;namespace SwiftClientCSharp
{
class Program
{
public static void Main(string[] args)
{
SwiftClient sc = new SwiftClient();
sc.DisableSSLCertificateValidation();
string url="https://192.168.179.61:8080/auth/v1.0";
string user="system:root";
string key="testpass";
Dictionary<string,string> headers = new Dictionary<string, string>();
Dictionary<string,string> query = new Dictionary<string, string>();
AuthResponse ar = sc.GetAuth(url,user,key,headers,query,false);
string token = ar.Headers["x-auth-token"];
string xurl = ar.Headers["x-storage-url"];
string srcContainerName = "CSharp中文名";
string srcObjectName = "CSharp中文名.txt";
UTF8Encoding utf8 = new UTF8Encoding();
byte[] utf8bytes = utf8.GetBytes(srcContainerName);
StringBuilder sb = new StringBuilder();
foreach (byte tmp in utf8bytes)
{
sb.AppendFormat("%{0:X2}",tmp);
}
string containerName = sb.ToString();
sb.Clear();
utf8bytes = utf8.GetBytes(srcObjectName);
foreach(byte tmp in utf8bytes)
{
sb.AppendFormat("%{0:X2}",tmp);
}
string objectName = sb.ToString();
sb.Clear();
Stream fstream = new FileStream(srcObjectName,FileMode.Open);
ContainerResponse cr = sc.PutContainer(xurl,token,containerName,headers,query);
ObjectResponse or = sc.PutObject(xurl,token,containerName,objectName,fstream,headers,query);
fstream.Close();
ContainerResponse cr2 = sc.GetContainer(xurl,token,containerName,headers,query,true);
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}