I am developing a windows store app with Box.net.
I am trying to upload files using backgrounduploader in winRT,
code snippet:
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;
}
It works fine with ascii encoded filename, but failed with others.
In header, it looks like this:
Content-Disposition: form-data; name="filename"; filename*=utf-8''Foo%E8%A4%87.jpg
Can someone help me with this?
I am stucked here for 2 days.
Thanks in advance!