public UploadDocumentResponse UploadDocument(string userId, string filename, string path, DateTime?documentDate, List <string> collectionIds, List <string> folderIds, CancellationToken cancellationToken)
        {
            RestRequest uploadRequest = CreateRestRequest(URI_RESOURCE, Method.POST, ContentType.MULTIPART_FORM_DATA);

            uploadRequest.AlwaysMultipartFormData = true;
            uploadRequest.AddParameter(GenerateFormParameter(RestApiConstants.METADATA, GenerateDocumentUploadJson(filename, path, documentDate, collectionIds, folderIds), ContentType.APPLICATION_JSON));
            DocumentStreamUtils.AddFileToUpload(uploadRequest, RestApiConstants.DOCUMENT, path, streamWrapper, cancellationToken);
            uploadRequest.Timeout          = int.MaxValue;
            uploadRequest.ReadWriteTimeout = int.MaxValue; // Cannot use Timeout.Infinite here because resthsharp only uses this if > 0

            var result = Execute <UploadDocumentResponse>(GetOAuthInfo(userId), uploadRequest);

            return(UnwrapResponse(result, new StatusCodeResponseHandler <UploadDocumentResponse>(HttpStatusCode.Created)));
        }
        public NewVersionUploadResponse UploadNewVersion(string userId, string id, string filename, string filepath, CancellationToken token)
        {
            RestRequest newVersionRequest = CreateRestRequest(URI_RESOURCE + id, Method.POST, ContentType.MULTIPART_FORM_DATA);

            newVersionRequest.AlwaysMultipartFormData = true;
            newVersionRequest.AddParameter(GenerateFormParameter("metadata", GetMetadata(filename, filepath), ContentType.APPLICATION_JSON));
            DocumentStreamUtils.AddFileToUpload(newVersionRequest, "document", filepath, streamWrapper, token);
            newVersionRequest.Timeout          = int.MaxValue;
            newVersionRequest.ReadWriteTimeout = int.MaxValue; // Cannot use Timeout.Infinite here because resthsharp only uses this if > 0

            var result = Execute <NewVersionUploadResponse>(GetOAuthInfo(userId), newVersionRequest);

            return(UnwrapResponse(result, new StatusCodeResponseHandler <NewVersionUploadResponse>(HttpStatusCode.Created)));
        }