public ToParamsDictionary ( ) : object>.SortedDictionary |
||
Результат | object>.SortedDictionary |
/// <summary> /// Uploads large file to cloudinary by dividing it to chunks. /// </summary> /// <param name="parameters">Parameters of file uploading.</param> /// <param name="bufferSize">Chunk (buffer) size (20 MB by default).</param> /// <returns></returns> /// <exception cref="System.ArgumentException"> /// Please use BasicRawUploadParams class for large raw file uploading! /// or /// The UploadLargeRaw method is intended to be used for large local file uploading and can't be used for remote file uploading! /// </exception> public RawUploadResult UploadLargeRaw(BasicRawUploadParams parameters, int bufferSize = 20 * 1024 * 1024) { if (parameters is RawUploadParams) throw new ArgumentException("Please use BasicRawUploadParams class for large raw file uploading!"); parameters.Check(); if (parameters.File.IsRemote) throw new ArgumentException("The UploadLargeRaw method is intended to be used for large local file uploading and can't be used for remote file uploading!"); string uri = m_api.ApiUrlV.Action("upload_large").ResourceType("raw").BuildUrl(); ResetInternalFileDescription(parameters.File, bufferSize); int partNumber = 1; string publicId = null; string uploadId = null; RawUploadResult result = null; while (!parameters.File.EOF) { var dict = parameters.ToParamsDictionary(); dict.Add("part_number", partNumber); if (partNumber > 1) { dict["public_id"] = publicId; dict["upload_id"] = uploadId; } if (parameters.File.IsLastPart()) dict["final"] = true; using (HttpWebResponse response = m_api.Call(HttpMethod.POST, uri, dict, parameters.File)) { var partResult = RawPartUploadResult.Parse(response); result = partResult; if (result.StatusCode != HttpStatusCode.OK) throw new WebException(String.Format( "An error has occured while uploading file (status code: {0}). {1}", partResult.StatusCode, partResult.Error != null ? partResult.Error.Message : "Unknown error")); if (partNumber == 1) { publicId = partResult.PublicId; uploadId = partResult.UploadId; } partNumber++; } } return result; }