Windows store apps 如何使用非ascii文件名上载到Box.net
我正在用Box.net开发一个windows应用商店应用程序 我正在尝试使用winRT中的backgrounduploader上载文件 代码段:Windows store apps 如何使用非ascii文件名上载到Box.net,windows-store-apps,box-api,Windows Store Apps,Box Api,我正在用Box.net开发一个windows应用商店应用程序 我正在尝试使用winRT中的backgrounduploader上载文件 代码段: public async Task<UploadOperation> CreateUploadOperationV2(StorageFile file, string name, string destFolderId) { BackgroundUploader uploader = new Backgrou
public async Task<UploadOperation> CreateUploadOperationV2(StorageFile file, string name, string destFolderId)
{
BackgroundUploader uploader = new BackgroundUploader();
uploader.Method = "POST";
uploader.SetRequestHeader("Authorization", "BoxAuth " + "api_key=" + mykey + "&auth_token=" + mytoken);
var uploadUrl = "https://www.box.net/api/2.0/"+ "files/content";
List<BackgroundTransferContentPart> parts = new List<BackgroundTransferContentPart>();
var part = new BackgroundTransferContentPart("filename", name);
part.SetFile(file);
parts.Add(part);
part = new BackgroundTransferContentPart("folder_id");
part.SetText(destFolderId);
parts.Add(part);
var uploadOperation = await uploader.CreateUploadAsync(new Uri(uploadUrl), parts);
return uploadOperation;
}
公共异步任务CreateUploadOperationV2(存储文件文件、字符串名称、字符串destFolderId)
{
BackgroundUploader uploader=新的BackgroundUploader();
uploader.Method=“POST”;
uploader.SetRequestHeader(“授权”、“BoxAuth”+“api_key=“+mykey+”&auth_token=“+mytoken”);
var uploadUrl=”https://www.box.net/api/2.0/“+”文件/内容;
列出零件=新列表();
var part=新的BackgroundTransferContentPart(“文件名”,名称);
part.SetFile(文件);
部分。添加(部分);
part=新的BackgroundTransferContentPart(“文件夹id”);
第.SetText部分(destFolderId);
部分。添加(部分);
var uploadOperation=await uploader.CreateUploadAsync(新Uri(uploadUrl),parts);
返回上传操作;
}
它适用于ascii编码的文件名,但对其他文件名无效
在标题中,它如下所示:
内容配置:表单数据;name=“filename”;文件名*=utf-8“Foo%E8%A4%87.jpg
有人能帮我吗
我在这里呆了两天
提前谢谢 @seanhc,我有这个问题。解决了,但我使用了java。May可以帮助您:
String url = "https://api.box.com/2.0/files/content";
HttpPost post = new HttpPost(url);
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, null, Charset.forName("UTF-8"));
HtmlUtils.addEntity(entity, "folder_id", path.id);
entity.addPart("filename", new CounterFileBody(post, file, onProgress, breakFlag));
post.setEntity(entity);
return BoxComHttpUtils.requestResponse(_storage, post, url);
开始正确,然后我将实体设置为:
MultipartEntity entity=新的MultipartEntity(HttpMultipartMode.BROWSER_兼容,null,Charset.forName(“UTF-8”)强>
找到解决办法