private MediaUploadResult UploadChunkedImpl(Stream media, int totalBytes, UploadMediaType mediaType, IEnumerable <KeyValuePair <string, object> > parameters) { var mediaId = this.UploadInitCommandImpl( parameters.EndWith( new KeyValuePair <string, object>("total_bytes", totalBytes), new KeyValuePair <string, object>("media_type", mediaType) )) .MediaId; const int maxChunkSize = 5 * 1000 * 1000; var chunk = new byte[maxChunkSize]; var remainingBytes = totalBytes; for (var segmentIndex = 0; remainingBytes > 0; segmentIndex++) { var readCount = media.Read(chunk, 0, Math.Min(remainingBytes, maxChunkSize)); if (readCount == 0) { break; } this.UploadAppendCommand(new Dictionary <string, object> { { "media_id", mediaId }, { "segment_index", segmentIndex }, { "media", new ArraySegment <byte>(chunk, 0, readCount) } }); remainingBytes -= readCount; } return(this.UploadFinalizeCommand(mediaId)); }
private MediaUploadResult UploadChunkedImpl(Stream media, int totalBytes, UploadMediaType mediaType, IEnumerable <KeyValuePair <string, object> > parameters) { string mediaId; using (var res = AccessUploadApi(new Dictionary <string, object>() { { "command", "INIT" }, { "total_bytes", totalBytes }, { "media_type", GetMediaTypeString(mediaType) } }.Concat(parameters))) using (var sr = new StreamReader(res.GetResponseStream())) mediaId = (string)JObject.Parse(sr.ReadToEnd())["media_id_string"]; const int maxChunkSize = 5 * 1000 * 1000; byte[] chunk = null; var remainingBytes = totalBytes; for (var segmentIndex = 0; remainingBytes > 0; segmentIndex++) { var chunkSize = remainingBytes < maxChunkSize ? remainingBytes : maxChunkSize; if (chunk == null || chunk.Length != chunkSize) { chunk = new byte[chunkSize]; } var readCount = media.Read(chunk, 0, chunkSize); if (readCount == 0) { break; } if (chunkSize != readCount) { var newChunk = new byte[readCount]; Buffer.BlockCopy(chunk, 0, newChunk, 0, readCount); chunk = newChunk; } this.AccessUploadApi(new Dictionary <string, object>() { { "command", "APPEND" }, { "media_id", mediaId }, { "segment_index", segmentIndex }, { "media", chunk } }).Close(); remainingBytes -= readCount; } using (var res = AccessUploadApi(new Dictionary <string, object>() { { "command", "FINALIZE" }, { "media_id", mediaId } })) using (var sr = new StreamReader(res.GetResponseStream())) { var json = sr.ReadToEnd(); var result = CoreBase.Convert <MediaUploadResult>(json); result.Json = json; return(result); } }
/// <summary> /// Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card. /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="additional_owners">A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, int totalBytes, UploadMediaType mediaType, IEnumerable <long> additional_owners = null) { var parameters = new Dictionary <string, object>(); if (additional_owners != null) { parameters.Add(nameof(additional_owners), additional_owners); } return(this.UploadChunkedImpl(media, totalBytes, mediaType, parameters)); }
/// <summary> /// 上传临时素材文件 /// 所有文件size必须大于5个字节 /// 图片(image):2MB,支持JPG,PNG格式 /// 语音(voice):2MB,播放长度不超过60s,支持AMR格式 /// 视频(video):10MB,支持MP4格式 /// 普通文件(file):20MB /// </summary> /// <param name="accessToken">调用接口凭证</param> /// <param name="fileFullName">文件名称(包含文件路径)</param> /// <param name="fileStream">文件流</param> /// <param name="mediaType">媒体文件类型</param> public MediaUploadResult UploadTemp(string accessToken, string fileFullName, Stream fileStream, UploadMediaType mediaType) { //string resultJson = HttpHelper.MaterialUploads(EntRequestUrl.UploadMedia.ToUrl(accessToken, mediaType.ToString()), fileName, mediaType.ToString(), fileStream); //MediaUploadResult result = JsonConvert.DeserializeObject<MediaUploadResult>(resultJson); //return result; var fileDictionary = new Dictionary<string, string>(); fileDictionary["media"] = fileFullName; string resultJson = HttpHelper.PostFileGetJson(EntRequestUrl.UploadMedia.ToUrl(accessToken, mediaType.ToString()), null, fileDictionary, null, null); MediaUploadResult result = JsonConvert.DeserializeObject<MediaUploadResult>(resultJson); return result; }
private MediaUploadResult UploadChunkedImpl(Stream media, long totalBytes, UploadMediaType mediaType, IEnumerable <KeyValuePair <string, object> > parameters, string urlPrefix, string urlSuffix) { var mediaId = this.UploadInitCommandImpl( parameters.EndWith( new KeyValuePair <string, object>("total_bytes", totalBytes), new KeyValuePair <string, object>("media_type", mediaType) ), urlPrefix, urlSuffix) .MediaId; const int maxChunkSize = 5 * 1000 * 1000; var chunk = new byte[maxChunkSize]; var remainingBytes = totalBytes; for (var segmentIndex = 0; remainingBytes > 0; segmentIndex++) { var readCount = media.Read(chunk, 0, (int)Math.Min(remainingBytes, maxChunkSize)); if (readCount == 0) { break; } this.UploadAppendCommand(new Dictionary <string, object> { { "media_id", mediaId }, { "segment_index", segmentIndex }, { "media", new ArraySegment <byte>(chunk, 0, readCount) } }); remainingBytes -= readCount; } var result = this.UploadFinalizeCommand(mediaId); while (result.ProcessingInfo?.CheckAfterSecs != null) { Thread.Sleep(result.ProcessingInfo.CheckAfterSecs.Value * 1000); result = this.UploadStatusCommand(mediaId); } if (result.ProcessingInfo?.State == "failed") { throw new MediaProcessingException(result); } return(result); }
/// <summary> /// 上传媒体文件。 /// 指定文件路径、文件格式和有效的访问令牌,将文件发送给微信服务器。 /// /// 注意:微信服务器只保存3天。 /// </summary> /// <param name="accessToken">访问令牌</param> /// <param name="type">文件类型。支持JPG, MP3, MP4, AMR等格式,详见<see cref="UploadMediaType"/></param> /// <param name="file">文件路径</param> /// <returns>若成功,则返回上传成功的时间、文件格式、以及资源ID;若失败,则抛出异常。</returns> /// <exception cref="WeixinException">下载不成功,则抛出该异常</exception> public static async Task <MediaUploadResultJson> Upload(string accessToken, UploadMediaType type, string file) { string api = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESSTOKEN&UploadMediaType=UPLOADMEDIATYPE"; api = api.Replace("ACCESSTOKEN", accessToken); api = api.Replace("UPLOADMEDIATYPE", type.ToString()); //var fileDictionary = new Dictionary<string, string>(); //fileDictionary["media"] = file; //return HttpUtilityPost.PostFileGetJson<MediaUploadResultJson>(url, null, fileDictionary, null); var httpResponseMessage = await HttpUtility.UploadFile(api, file); byte[] responseData = await httpResponseMessage.Content.ReadAsByteArrayAsync(); string resp = Encoding.UTF8.GetString(responseData); var json = resp.FromJson <MediaUploadResultJson>(); return(json); }
/// <summary> /// Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation. /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="additional_owners">A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The result for the uploaded media.</returns> public Task <MediaUploadResult> UploadChunkedAsync(Stream media, int totalBytes, UploadMediaType mediaType, IEnumerable <long> additional_owners = null, CancellationToken cancellationToken = default(CancellationToken)) { var parameters = new Dictionary <string, object>(); if (additional_owners != null) { parameters.Add(nameof(additional_owners), additional_owners); } return(this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, parameters, cancellationToken)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task <MediaUploadResult> UploadChunkedAsync(Stream media, int totalBytes, UploadMediaType mediaType, IDictionary <string, object> parameters, CancellationToken cancellationToken = default(CancellationToken)) { return(this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, parameters, cancellationToken)); }
private Task <MediaUploadResult> UploadChunkedAsyncImpl(Stream media, int totalBytes, UploadMediaType mediaType, IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken) { return(this.AccessUploadApiAsync( new Dictionary <string, object>() { { "command", "INIT" }, { "total_bytes", totalBytes }, { "media_type", GetMediaTypeString(mediaType) } }.Concat(parameters), cancellationToken) .ReadResponse(s => (string)JObject.Parse(s)["media_id_string"], cancellationToken) .Done(mediaId => { var tasks = new List <Task>(); const int maxChunkSize = 5 * 1000 * 1000; var remainingBytes = totalBytes; for (var i = 0; remainingBytes > 0; i++) { var segmentIndex = i; // to capture the variable var chunkSize = remainingBytes < maxChunkSize ? remainingBytes : maxChunkSize; var chunk = new byte[chunkSize]; var readCount = media.Read(chunk, 0, chunkSize); if (readCount == 0) { break; } if (chunkSize != readCount) { var newChunk = new byte[readCount]; Buffer.BlockCopy(chunk, 0, newChunk, 0, readCount); chunk = newChunk; } remainingBytes -= readCount; tasks.Add( this.AccessUploadApiAsync( new Dictionary <string, object>() { { "command", "APPEND" }, { "media_id", mediaId }, { "segment_index", segmentIndex }, { "media", chunk } }, cancellationToken ) .Done(res => res.Dispose(), cancellationToken) ); } return WhenAll(tasks) .Done(() => { return AccessUploadApiAsync( new Dictionary <string, object>() { { "command", "FINALIZE" }, { "media_id", mediaId } }, cancellationToken) .ReadResponse(s => CoreBase.Convert <MediaUploadResult>(s), cancellationToken); }, cancellationToken ) .Unwrap(); }, cancellationToken) .Unwrap()); }
/// <summary> /// Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation. /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="additional_owners">A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The result for the uploaded media.</returns> public Task<MediaUploadResult> UploadChunkedAsync(Stream media, UploadMediaType mediaType, IEnumerable<long> additional_owners = null, CancellationToken cancellationToken = default(CancellationToken)) { return this.UploadChunkedAsync(media, checked((int)media.Length), mediaType, additional_owners, cancellationToken); }
/// <summary> /// 获取素材列表 /// </summary> /// <param name="accessToken">调用接口凭证</param> /// <param name="agentid">企业应用的id,整型。可在应用的设置页面查看</param> /// <param name="mediaType">素材类型</param> /// <param name="offset">从该类型素材的该偏移位置开始返回,0表示从第一个素材 返回</param> /// <param name="count">返回素材的数量,取值在1到50之间</param> public MaterialGetBatch GetMaterialBatch(string accessToken, int agentid, UploadMediaType mediaType, int offset, int count) { MaterialGetBatch materialBatch = new MaterialGetBatch(); var data = new { type = mediaType.ToString(), agentid = agentid, offset = offset, count = count }; var dataJson = JsonConvert.SerializeObject(data); var resultJson = HttpHelper.PostString(EntRequestUrl.GetMaterialBatch.ToUrl(accessToken), dataJson); WeChatResult result = JsonConvert.DeserializeObject<WeChatResult>(resultJson); if (!result.IsSuccess) { return materialBatch; } JObject dataObj = (JObject)JsonConvert.DeserializeObject(resultJson); var type = dataObj["type"].ToString(); UploadMediaType mt = (UploadMediaType)Enum.Parse(typeof(UploadMediaType), type); if (mt == UploadMediaType.mpnews) { materialBatch.MediaComplexList = new List<MediaComplex>(); foreach (var item in dataObj["itemlist"]) { string value = item.ToString(); MediaComplex ma = JsonConvert.DeserializeObject<MediaComplex>(value); ma.articles = new List<Material>(); JObject articles = (JObject)JsonConvert.DeserializeObject(value); foreach (var article in articles["content"]["articles"]) { ma.articles.Add(JsonConvert.DeserializeObject<Material>(article.ToString())); } materialBatch.MediaComplexList.Add(ma); } } else { materialBatch.MediaSimpleList = new List<MediaSimple>(); foreach (var item in dataObj["itemlist"]) { string value = item.ToString(); MediaSimple ma = JsonConvert.DeserializeObject<MediaSimple>(value); materialBatch.MediaSimpleList.Add(ma); } } materialBatch.TotalCount = int.Parse(dataObj["total_count"].ToString()); materialBatch.ItemCount = int.Parse(dataObj["item_count"].ToString()); return materialBatch; }
/// <summary> /// Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card. /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="additional_owners">A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, UploadMediaType mediaType, IEnumerable<long> additional_owners = null) { return this.UploadChunked(media, checked((int)media.Length), mediaType, additional_owners); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, int totalBytes, UploadMediaType mediaType, object parameters) { return this.UploadChunkedImpl(media, totalBytes, mediaType, InternalUtils.ResolveObject(parameters)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card.</para> /// <para>Available parameters:</para> /// <para>- <c>string</c> media_category (optional)</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, UploadMediaType mediaType, params Expression <Func <string, object> >[] parameters) { return(this.UploadChunked(media, media.Length, mediaType, parameters)); }
/// <summary> /// Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation. /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="media_category">A string enum value which identifies a media usecase.</param> /// <param name="additional_owners">A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The result for the uploaded media.</returns> public Task <MediaUploadResult> UploadChunkedWithRetryAsync(Stream media, UploadMediaType mediaType, int retryCount, int retryDelayInMilliseconds, string media_category = null, IEnumerable <long> additional_owners = null, CancellationToken cancellationToken = default(CancellationToken), IProgress <UploadChunkedProgressInfo> progress = null) { return(this.UploadChunkedWithRetryAsync(media, media.Length, mediaType, retryCount, retryDelayInMilliseconds, media_category, additional_owners, cancellationToken, progress)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>string</c> media_category (optional)</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task <MediaUploadResult> UploadChunkedWithRetryAsync(Stream media, UploadMediaType mediaType, object parameters, int retryCount, int retryDelayInMilliseconds, CancellationToken cancellationToken = default(CancellationToken), IProgress <UploadChunkedProgressInfo> progress = null) { return(this.UploadChunkedWithRetryAsync(media, media.Length, mediaType, retryCount, retryDelayInMilliseconds, parameters, cancellationToken, progress)); }
/// <summary> /// Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation. /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="media_category">A string enum value which identifies a media usecase.</param> /// <param name="additional_owners">A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The result for the uploaded media.</returns> public Task <MediaUploadResult> UploadChunkedWithRetryAsync(Stream media, long totalBytes, UploadMediaType mediaType, int retryCount, int retryDelayInMilliseconds, string media_category = null, IEnumerable <long> additional_owners = null, CancellationToken cancellationToken = default(CancellationToken), IProgress <UploadChunkedProgressInfo> progress = null) { var parameters = new Dictionary <string, object>(); if (media_category != null) { parameters.Add(nameof(media_category), media_category); } if (additional_owners != null) { parameters.Add(nameof(additional_owners), additional_owners); } return(this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, parameters, retryCount, retryDelayInMilliseconds, cancellationToken, progress)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task <MediaUploadResult> UploadChunkedAsync(Stream media, UploadMediaType mediaType, object parameters, CancellationToken cancellationToken = default(CancellationToken)) { return(this.UploadChunkedAsync(media, checked ((int)media.Length), mediaType, parameters, cancellationToken)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card.</para> /// <para>Available parameters:</para> /// <para>- <c>string</c> media_category (optional)</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, UploadMediaType mediaType, IDictionary <string, object> parameters) { return(this.UploadChunked(media, media.Length, mediaType, parameters)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, int totalBytes, UploadMediaType mediaType, params Expression<Func<string, object>>[] parameters) { return this.UploadChunkedImpl(media, totalBytes, mediaType, InternalUtils.ExpressionsToDictionary(parameters)); }
/// <summary> /// Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card. /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="media_category">A string enum value which identifies a media usecase.</param> /// <param name="additional_owners">A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, UploadMediaType mediaType, string media_category = null, IEnumerable <long> additional_owners = null) { return(this.UploadChunked(media, media.Length, mediaType, media_category, additional_owners)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, UploadMediaType mediaType, params Expression<Func<string, object>>[] parameters) { return this.UploadChunked(media, checked((int)media.Length), mediaType, parameters); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>string</c> media_category (optional)</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task <MediaUploadResult> UploadChunkedWithRetryAsync(Stream media, long totalBytes, UploadMediaType mediaType, int retryCount, int retryDelayInMilliseconds, params Expression <Func <string, object> >[] parameters) { return(this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, InternalUtils.ExpressionsToDictionary(parameters), retryCount, retryDelayInMilliseconds, CancellationToken.None)); }
private static string GetMediaTypeString(UploadMediaType mediaType) { return mediaType == UploadMediaType.Video ? "video/mp4" : "application/octet-stream"; }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, int totalBytes, UploadMediaType mediaType, params Expression <Func <string, object> >[] parameters) { return(this.UploadChunkedImpl(media, totalBytes, mediaType, InternalUtils.ExpressionsToDictionary(parameters))); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>string</c> media_category (optional)</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task <MediaUploadResult> UploadChunkedWithRetryAsync(Stream media, long totalBytes, UploadMediaType mediaType, int retryCount, int retryDelayInMilliseconds, object parameters, CancellationToken cancellationToken = default(CancellationToken), IProgress <UploadChunkedProgressInfo> progress = null) { return(this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, InternalUtils.ResolveObject(parameters), retryCount, retryDelayInMilliseconds, cancellationToken, progress)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, int totalBytes, UploadMediaType mediaType, IDictionary <string, object> parameters) { return(this.UploadChunkedImpl(media, totalBytes, mediaType, parameters)); }
private Task<MediaUploadResult> UploadChunkedAsyncImpl(Stream media, int totalBytes, UploadMediaType mediaType, IEnumerable<KeyValuePair<string, object>> parameters, CancellationToken cancellationToken) { return this.AccessUploadApiAsync( new Dictionary<string, object>() { { "command", "INIT" }, { "total_bytes", totalBytes }, { "media_type", GetMediaTypeString(mediaType) } }.Concat(parameters), cancellationToken) .ContinueWith( t => InternalUtils.ReadResponse(t, s => (string)JObject.Parse(s)["media_id_string"], cancellationToken), cancellationToken ) .Unwrap() .ContinueWith(t => { if(t.IsFaulted) t.Exception.InnerException.Rethrow(); var mediaId = t.Result; var tasks = new List<Task>(); const int maxChunkSize = 5 * 1000 * 1000; var remainingBytes = totalBytes; for (var i = 0; remainingBytes > 0; i++) { var segmentIndex = i; // to capture the variable var chunkSize = remainingBytes < maxChunkSize ? remainingBytes : maxChunkSize; var chunk = new byte[chunkSize]; var readCount = media.Read(chunk, 0, chunkSize); if (readCount == 0) break; if (chunkSize != readCount) { var newChunk = new byte[readCount]; Buffer.BlockCopy(chunk, 0, newChunk, 0, readCount); chunk = newChunk; } remainingBytes -= readCount; tasks.Add( this.AccessUploadApiAsync( new Dictionary<string, object>() { { "command", "APPEND" }, { "media_id", mediaId }, { "segment_index", segmentIndex }, { "media", chunk } }, cancellationToken ) .ContinueWith(t2 => { if (t2.IsFaulted) t2.Exception.InnerException.Rethrow(); t2.Result.Dispose(); }, cancellationToken) ); } return WhenAll(tasks) .ContinueWith(x => { if(x.IsFaulted) x.Exception.InnerException.Rethrow(); return AccessUploadApiAsync( new Dictionary<string, object>() { { "command", "FINALIZE" }, { "media_id", mediaId } }, cancellationToken) .ContinueWith( y => InternalUtils.ReadResponse(y, s => CoreBase.Convert<MediaUploadResult>(s), cancellationToken), cancellationToken ) .Unwrap(); }, cancellationToken ) .Unwrap(); }, cancellationToken) .Unwrap(); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, int totalBytes, UploadMediaType mediaType, object parameters) { return(this.UploadChunkedImpl(media, totalBytes, mediaType, InternalUtils.ResolveObject(parameters))); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task <MediaUploadResult> UploadChunkedAsync(Stream media, int totalBytes, UploadMediaType mediaType, params Expression <Func <string, object> >[] parameters) { return(this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, InternalUtils.ExpressionsToDictionary(parameters), CancellationToken.None)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>string</c> media_category (optional)</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task <MediaUploadResult> UploadChunkedAsync(Stream media, UploadMediaType mediaType, object parameters, CancellationToken cancellationToken = default(CancellationToken), IProgress <UploadChunkedProgressInfo> progress = null) { return(this.UploadChunkedAsync(media, media.Length, mediaType, parameters, cancellationToken, progress)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task <MediaUploadResult> UploadChunkedAsync(Stream media, int totalBytes, UploadMediaType mediaType, object parameters, CancellationToken cancellationToken = default(CancellationToken)) { return(this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, InternalUtils.ResolveObject(parameters), cancellationToken)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, UploadMediaType mediaType, object parameters) { return(this.UploadChunked(media, checked ((int)media.Length), mediaType, parameters)); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task <MediaUploadResult> UploadChunkedAsync(Stream media, UploadMediaType mediaType, params Expression <Func <string, object> >[] parameters) { return(this.UploadChunkedAsync(media, checked ((int)media.Length), mediaType, parameters)); }
/// <summary> /// Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card. /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="additional_owners">A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, UploadMediaType mediaType, IEnumerable <long> additional_owners = null) { return(this.UploadChunked(media, checked ((int)media.Length), mediaType, additional_owners)); }
/// <summary> /// Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation. /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="additional_owners">A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The result for the uploaded media.</returns> public Task <MediaUploadResult> UploadChunkedAsync(Stream media, UploadMediaType mediaType, IEnumerable <long> additional_owners = null, CancellationToken cancellationToken = default(CancellationToken)) { return(this.UploadChunkedAsync(media, checked ((int)media.Length), mediaType, additional_owners, cancellationToken)); }
private static string GetMediaTypeString(UploadMediaType mediaType) { return(mediaType == UploadMediaType.Video ? "video/mp4" : "application/octet-stream"); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, int totalBytes, UploadMediaType mediaType, IDictionary<string, object> parameters) { return this.UploadChunkedImpl(media, totalBytes, mediaType, parameters); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task<MediaUploadResult> UploadChunkedAsync(Stream media, int totalBytes, UploadMediaType mediaType, params Expression<Func<string, object>>[] parameters) { return this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, InternalUtils.ExpressionsToDictionary(parameters), CancellationToken.None); }
/// <summary> /// Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card. /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="additional_owners">A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, int totalBytes, UploadMediaType mediaType, IEnumerable<long> additional_owners = null) { var parameters = new Dictionary<string, object>(); if (additional_owners != null) parameters.Add(nameof(additional_owners), additional_owners); return this.UploadChunkedImpl(media, totalBytes, mediaType, parameters); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task<MediaUploadResult> UploadChunkedAsync(Stream media, int totalBytes, UploadMediaType mediaType, IDictionary<string, object> parameters, CancellationToken cancellationToken = default(CancellationToken)) { return this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, parameters, cancellationToken); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns>The result for the uploaded media.</returns> public MediaUploadResult UploadChunked(Stream media, UploadMediaType mediaType, object parameters) { return this.UploadChunked(media, checked((int)media.Length), mediaType, parameters); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>string</c> media_category (optional)</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task <MediaUploadResult> UploadChunkedAsync(Stream media, long totalBytes, UploadMediaType mediaType, IDictionary <string, object> parameters, CancellationToken cancellationToken = default(CancellationToken), IProgress <UploadChunkedProgressInfo> progress = null) { return(this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, parameters, 0, 0, cancellationToken, progress)); }
private MediaUploadResult UploadChunkedImpl(Stream media, int totalBytes, UploadMediaType mediaType, IEnumerable<KeyValuePair<string, object>> parameters) { string mediaId; using(var res = AccessUploadApi(new Dictionary<string, object>() { { "command", "INIT" }, { "total_bytes", totalBytes }, { "media_type", GetMediaTypeString(mediaType) } }.Concat(parameters))) using(var sr = new StreamReader(res.GetResponseStream())) mediaId = (string)JObject.Parse(sr.ReadToEnd())["media_id_string"]; const int maxChunkSize = 5 * 1000 * 1000; byte[] chunk = null; var remainingBytes = totalBytes; for(var segmentIndex = 0; remainingBytes > 0; segmentIndex++) { var chunkSize = remainingBytes < maxChunkSize ? remainingBytes : maxChunkSize; if(chunk == null || chunk.Length != chunkSize) chunk = new byte[chunkSize]; var readCount = media.Read(chunk, 0, chunkSize); if(readCount == 0) break; if(chunkSize != readCount) { var newChunk = new byte[readCount]; Buffer.BlockCopy(chunk, 0, newChunk, 0, readCount); chunk = newChunk; } this.AccessUploadApi(new Dictionary<string, object>() { { "command", "APPEND" }, { "media_id", mediaId }, { "segment_index", segmentIndex }, { "media", chunk } }).Close(); remainingBytes -= readCount; } using(var res = AccessUploadApi(new Dictionary<string, object>() { { "command", "FINALIZE" }, { "media_id", mediaId } })) using(var sr = new StreamReader(res.GetResponseStream())) { var json = sr.ReadToEnd(); var result = CoreBase.Convert<MediaUploadResult>(json); result.Json = json; return result; } }
/// <summary> /// Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation. /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="additional_owners">A comma-separated string of user IDs to set as additional owners who are allowed to use the returned media_id in Tweets or Cards.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The result for the uploaded media.</returns> public Task<MediaUploadResult> UploadChunkedAsync(Stream media, int totalBytes, UploadMediaType mediaType, IEnumerable<long> additional_owners = null, CancellationToken cancellationToken = default(CancellationToken)) { var parameters = new Dictionary<string, object>(); if (additional_owners != null) parameters.Add("additional_owners", additional_owners); return this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, parameters, cancellationToken); }
/// <summary> /// 上传其他类型永久素材 /// 所有文件size必须大于5个字节 /// 图片(image):2MB,支持JPG,PNG格式 /// 语音(voice):2MB,播放长度不超过60s,支持AMR格式 /// 视频(video):10MB,支持MP4格式 /// 普通文件(file):20MB /// 整个企业图文消息素材和图片素材数目的上限为5000,其他类型为1000 /// 超出素材数量限制返回错误码45028 /// </summary> /// <param name="accessToken">调用接口凭证</param> /// <param name="agentid">企业应用的id,整型。可在应用的设置页面查看</param> /// <param name="fileFullName">文件名称(包含文件路径)</param> /// <param name="mediaType">媒体文件类型</param> /// <returns></returns> public MaterialUploadResult UploadOtherMaterial(string accessToken, int agentid, string fileFullName, UploadMediaType mediaType) { var fileDictionary = new Dictionary<string, string>(); fileDictionary["media"] = fileFullName; string resultJson = HttpHelper.PostFileGetJson(EntRequestUrl.AddMaterial.ToUrl(accessToken, agentid, mediaType.ToString()), null, fileDictionary, null, null); MaterialUploadResult result = JsonConvert.DeserializeObject<MaterialUploadResult>(resultJson); return result; }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task<MediaUploadResult> UploadChunkedAsync(Stream media, UploadMediaType mediaType, object parameters, CancellationToken cancellationToken = default(CancellationToken)) { return this.UploadChunkedAsync(media, checked((int)media.Length), mediaType, parameters, cancellationToken); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="totalBytes">The size of the media being uploaded in bytes.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task<MediaUploadResult> UploadChunkedAsync(Stream media, int totalBytes, UploadMediaType mediaType, object parameters, CancellationToken cancellationToken = default(CancellationToken)) { return this.UploadChunkedAsyncImpl(media, totalBytes, mediaType, InternalUtils.ResolveObject(parameters), cancellationToken); }
/// <summary> /// <para>Uploads videos or chunked images to Twitter for use in a Tweet or Twitter-hosted Card as an asynchronous operation.</para> /// <para>Available parameters:</para> /// <para>- <c>string</c> media_category (optional)</para> /// <para>- <c>IEnumerbale<long></c> additional_owners (optional)</para> /// </summary> /// <param name="media">The raw binary file content being uploaded.</param> /// <param name="mediaType">The type of the media being uploaded.</param> /// <param name="parameters">The parameters.</param> /// <returns> /// <para>The task object representing the asynchronous operation.</para> /// <para>The Result property on the task object returns the result for the uploaded media.</para> /// </returns> public Task <MediaUploadResult> UploadChunkedWithRetryAsync(Stream media, UploadMediaType mediaType, int retryCount, int retryDelayInMilliseconds, params Expression <Func <string, object> >[] parameters) { return(this.UploadChunkedWithRetryAsync(media, media.Length, mediaType, retryCount, retryDelayInMilliseconds, parameters)); }