public void FileUploadTest() { Byte[] data = null; using (var stream = File.OpenRead("R:/1.png")) { data = stream.ReadAsBytes(); } var future = Bmob.FileUploadTaskAsync(new BmobLocalFile(data, "21.png")); FinishedCallback(future.Result, null); }
// async方式异步请求处理,非阻塞访问 private async void uploadBtn_Click(object sender, EventArgs e) { formstatus.Text = "正在上传..."; var Result = await Bmob.FileUploadTaskAsync(fileText.Text); FinishedCallback(Result, resultText); bmobFile = Result; enterDba.Enabled = true; formstatus.Text = "上传成功!"; }
public void FileUploadHugeTest() { try { Byte[] data = null; using (var stream = File.OpenRead("E:/local/opt/eclipse-jee-luna-R-win32-x86_64.zip")) { data = stream.ReadAsBytes(); } var future = Bmob.FileUploadTaskAsync(new BmobLocalFile(data, "超大文件.zip")); FinishedCallback(future.Result, null); } catch { return; } Assert.Fail("should throw exception. but it sees not!"); }