/// <summary> /// 上传多媒体文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpload_Click(object sender, EventArgs e) { string userName = lbPublicAccount.SelectedValue; MultiMediaTypeEnum type = (MultiMediaTypeEnum)Enum.Parse(typeof(MultiMediaTypeEnum), lbMultiMediaType.SelectedValue); string filename = fileUpload.FileName; byte[] bytes = fileUpload.FileBytes; ErrorMessage errorMessage; MultiMediaUploadResult result = MultiMediaHelper.Upload(userName, type, filename, bytes, out errorMessage); if (errorMessage.IsSuccess && result != null) { hlShowMultiMedia.NavigateUrl = MultiMediaHelper.GetDownloadUrl(AccessToken.Get(userName).access_token, result.MediaId); ltrMessage.Text = "上传多媒体文件成功。"; } else { hlShowMultiMedia.NavigateUrl = string.Format("javascript:alert('上传多媒体文件失败。\r\n{0}');", errorMessage); ltrMessage.Text = string.Format("上传多媒体文件失败。\r\n{0}", errorMessage); } }
/// <summary> /// 获取下载临时素材(媒体文件,不包括视频)的链接 /// </summary> /// <param name="token">许可令牌</param> /// <param name="mediaId">媒体id</param> /// <returns>返回下载多媒体文件的链接</returns> public static string GetDownloadUrlOfTemporary(string token, string mediaId) { return(MultiMediaHelper.GetDownloadUrl(token, mediaId)); }