private void SendImage() { if (conn.ConnectionState != agsXMPP.XmppConnectionState.Connected && conn.ConnectionState != agsXMPP.XmppConnectionState.SessionStarted) { MessageBox.Show("请连接后再上传文件"); return; } if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { return; } // Path : /{org_name}/{app_name}/chatfiles string path = conn.GetUrl("chatfiles"); PostedFileResp resp = PostedFileManager.PostFile(path, conn.TokenData.access_token, openFileDialog1.FileName); string title = BuildMsgTitle(conn.UserName); //edChat.AppendHtml(title, Color.Blue); //edChat.AppendNewLine(); byte[] bytes = SdkUtils.DownloadThumbnail(resp.uri + "/" + resp.entities[0].uuid, resp.entities[0].share_secret, conn.TokenData.access_token); //edChat.AppendImageBytes(bytes); //edChat.AppendNewLine(2); conn.SendFile(toUserName, resp); }
private void SendAudio(string audioFileName) { string path = conn.GetUrl("chatfiles"); PostedFileResp resp = PostedFileManager.PostFile(path, conn.TokenData.access_token, audioFileName); string title = BuildMsgTitle(conn.UserName); //edChat.AppendHtml(title, Color.Blue); //edChat.AppendNewLine(); byte[] bytes = SdkUtils.DownloadThumbnail(resp.uri + "/" + resp.entities[0].uuid, resp.entities[0].share_secret, conn.TokenData.access_token); AppendAudioTag("我的语音"); conn.SendFile(toUserName, resp); }