private async void Button_Click_2(object sender, RoutedEventArgs e) { byte[] data = System.Text.Encoding.UTF8.GetBytes(txb_word.Text.Trim()); AVFile file = new AVFile("mytxtFile.txt", data, new Dictionary <string, object>() { { "author", "AVOSCloud" } }); await file.SaveAsync().ContinueWith( t => { if (!t.IsFaulted) { MessageBox.Show(file.ObjectId); } else { } }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext()); #region 以下代码可以实现将本地文件上传到AVOS Cloud 的服务端,进行保存,并且可以跟踪上传进度。 AVFile localFile = AVFile.CreateFileWithLocalPath("screenshot.PNG", Path.Combine("<Local Folder Path>", "screenshot.PNG")); await localFile.SaveAsync(new Progress <AVUploadProgressEventArgs>(p => { var progress = p.Progress; })); #endregion }
private void UploadFile() { // var file = AVFile.CreateFileWithLocalPath("character.png", // System.IO.Path.Combine(Application.persistentDataPath, "character.png")); var file = AVFile.CreateFileWithLocalPath("Hello.txt", System.IO.Path.Combine(Application.persistentDataPath, "Hello.txt")); file.SaveAsync(); }
void OnGUI() { GUI.Label(new Rect(260, 50, 160, 50), fildId); if (GUI.Button(new Rect(50, 50, 200, 50), "Save")) { AVFile file = AVFile.CreateFileWithLocalPath("SaveA.xml", Path.Combine(Application.persistentDataPath, "SaveA.xml")); { file.MetaData.Add("UserID", UserID); file.SaveAsync().ContinueWith(t => { Debug.Log(t.IsFaulted); if (!t.IsFaulted) { fildId = file.ObjectId; } else { Debug.Log(t.Exception.Message); Debug.LogException(t.Exception); } }); } } }
private async void Button_Click_4(object sender, RoutedEventArgs e) { string filePath = Path.Combine("Shared", "Media", "GuoJiGe.mp3"); AVFile file = AVFile.CreateFileWithLocalPath("GuoJiGe.mp3", filePath); await file.SaveAsync(); }