コード例 #1
0
        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
        }
コード例 #2
0
        public void AVFile_Image_From_Url()
        {
            AVClient.Initialize("uay57kigwe0b6f5n0e1d4z4xhydsml3dor24bzwvzr57wdap", "kfgz7jjfsk55r5a8a3y4ttd3je1ko11bkibcikonk32oozww");
            AVFile avfile = new AVFile("yoshi.jpg", "http://ww3.sinaimg.cn/bmiddle/596b0666gw1ed70eavm5tg20bq06m7wi.gif");

            avfile.SaveAsync().Wait();
        }
コード例 #3
0
        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
        }
コード例 #4
0
ファイル: Main.xaml.cs プロジェクト: z-wl/TnecnetOO
        //选择图片,发送图片
        private async void Btnsendimage_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter = "ALL Image Files|*.*";
            if ((bool)openFile.ShowDialog())
            {
                var image = new AVFile(openFile.SafeFileName, openFile.OpenFile());
                await image.SaveAsync();

                var imageMessage = new AVIMImageMessage
                {
                    File        = image,
                    TextContent = "[图片]"
                };
                await Conversation.SendMessageAsync(imageMessage);

                InviteFriend.MessageList.Add(new Message(imageMessage));
                //TODO:
                received.ItemsSource = null;
                received.ItemsSource = InviteFriend.MessageList;
                //聚焦最新的消息
                received.ScrollIntoView(received.Items.GetItemAt(InviteFriend.MessageList.Count - 1));
            }
            openFile.OpenFile().Close();
        }
コード例 #5
0
        private async void SendAudio()
        {
            StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;

            var AudioFile = await local.OpenStreamForReadAsync(recordVideoFileName);

            AVFile testFile = new AVFile(recordVideoFileName, AudioFile);
            await testFile.SaveAsync();
        }
コード例 #6
0
        public void AVFile_File_From_String_QCloud()
        {
            AVClient.Initialize("JXyR8vfpeSr8cfaYnob2zYl0-9Nh9j0Va", "Fgq2YlPdnP1KJEoWyF5tk2az");
            AVClient.EnableDebugLog((obj) =>
            {
                Trace.WriteLine(obj);
            });
            byte[] data = System.Text.Encoding.UTF8.GetBytes("LeanCloud is great!");
            AVFile file = new AVFile("resume.txt", data);

            file.SaveAsync().Wait();
        }
コード例 #7
0
        public void AVFile_File_From_String()
        {
            AVClient.Initialize("uay57kigwe0b6f5n0e1d4z4xhydsml3dor24bzwvzr57wdap", "kfgz7jjfsk55r5a8a3y4ttd3je1ko11bkibcikonk32oozww");
            AVClient.EnableDebugLog((obj) =>
            {
                Trace.WriteLine(obj);
            });
            byte[] data = System.Text.Encoding.UTF8.GetBytes("LeanCloud is great good wonderful great good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderful!");
            AVFile file = new AVFile("resume.txt", data);

            file.SaveAsync().Wait();
        }
コード例 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override Task <AVIMMessage> MakeAsync()
 {
     return(fileState.SaveAsync().OnSuccess(_ =>
     {
         this.Attribute(AVIMProtocol.LCTYPE, -2);
         this.Attribute(AVIMProtocol.LCTEXT, "Image");
         var fileData = new Dictionary <string, object>();
         fileData["url"] = fileState.Url.ToString();
         fileData["objId"] = fileState.ObjectId;
         this.Attribute(AVIMProtocol.LCFILE, fileData);
         return this as AVIMMessage;
     }));
 }
コード例 #9
0
        public void AVFile_File_From_File_QCloud()
        {
            AVClient.Initialize("JXyR8vfpeSr8cfaYnob2zYl0-9Nh9j0Va", "Fgq2YlPdnP1KJEoWyF5tk2az");
            AVClient.EnableDebugLog((obj) =>
            {
                Trace.WriteLine(obj);
            });
            var ss         = Directory.GetCurrentDirectory();
            var path       = Path.Combine(ss, "Jay.mp3");
            var fileStream = new FileStream(path, FileMode.Open);

            // read from file or write to file
            AVFile file = new AVFile("Jay.mp3", fileStream);

            file.SaveAsync().Wait();
        }
コード例 #10
0
    async private void UploadPictures()
    {
        List <AVUser> selectedUserList = new List <AVUser>();

        if (this.Page.Session[SESSIONKEY] == null)
        {
            this.InitUsers();
        }

        var users = (IEnumerable <AVUser>) this.Page.Session[SESSIONKEY];

        foreach (ListItem item in this.choosen_users.Items)
        {
            if (item.Selected)
            {
                AVUser user = users.First(u => u.ObjectId == item.Value);
                selectedUserList.Add(user);
            }
        }

        Random random    = new Random();
        int    userCount = selectedUserList.Count;

        AVObject selectedCategory = await AVObject.GetQuery("Category").GetAsync(this.child_category.SelectedValue);

        int hack_pop = this.pop_check.Checked ? 1 : 0;

        var uploadedFiles = this.file_upload.PostedFiles;

        foreach (var file in uploadedFiles)
        {
            var fullSizeImage  = this.ResizeImageWithSize(file.InputStream, fullSizeRect);
            var thumbnailImage = this.ResizeImageWithSize(file.InputStream, thumbnailSizeRect);

            AVFile imageFull = new AVFile(file.FileName, this.GetBytesFromImage(fullSizeImage));
            await imageFull.SaveAsync();

            AVFile imageThumbnail = new AVFile(string.Format("thumbnail_{0}", file.FileName), this.GetBytesFromImage(thumbnailImage));
            await imageThumbnail.SaveAsync();

            this.SaveBlog(selectedUserList[random.Next(userCount)], selectedCategory.ObjectId, imageThumbnail.ObjectId, imageFull.ObjectId, hack_pop);
        }
    }
コード例 #11
0
 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);
                 }
             });
         }
     }
 }
コード例 #12
0
 void photoChooserTask_Completed(object sender, PhotoResult e)
 {
     if (e.TaskResult == TaskResult.OK)
     {
         //MessageBox.Show(e.ChosenPhoto.Length.ToString());
         AVFile file = new AVFile("WPSelected.png", e.ChosenPhoto);
         file.SaveAsync().ContinueWith(
             t =>
         {
             if (!t.IsFaulted)
             {
                 MessageBox.Show(file.ObjectId);
             }
             else
             {
             }
         }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext());
         //Code to display the photo on the page in an image control named myImage.
         //System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
         //bmp.SetSource(e.ChosenPhoto);
         //myImage.Source = bmp;
     }
 }
コード例 #13
0
        void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                //MessageBox.Show(e.ChosenPhoto.Length.ToString());
                AVFile file = new AVFile("WPSelected.png", e.ChosenPhoto);
                file.SaveAsync().ContinueWith(
                t =>
                {
                    if (!t.IsFaulted)
                    {
                        MessageBox.Show(file.ObjectId);
                    }
                    else
                    {

                    }
                }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext());
                //Code to display the photo on the page in an image control named myImage.
                //System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                //bmp.SetSource(e.ChosenPhoto);
                //myImage.Source = bmp;
            }
        }
コード例 #14
0
 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();
 }