Пример #1
0
 /// <summary>
 /// Upload file
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='fileContent'>
 /// File to upload.
 /// </param>
 /// <param name='fileName'>
 /// File name to upload. Name has to be spelled exactly as written here.
 /// </param>
 public static System.IO.Stream UploadFileViaBody(this IFormdata operations, System.IO.Stream fileContent, string fileName)
 {
     return(Task.Factory.StartNew(s => ((IFormdata)s).UploadFileViaBodyAsync(fileContent, fileName), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Пример #2
0
 /// <summary>
 /// Upload file
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='fileContent'>
 /// File to upload.
 /// </param>
 public static Stream UploadFileViaBody(this IFormdata operations, Stream fileContent)
 {
     return(operations.UploadFileViaBodyAsync(fileContent).GetAwaiter().GetResult());
 }
Пример #3
0
        /// <summary>
        /// Upload file
        /// </summary>
        /// <param name='operations'>
        /// The operations group for this extension method.
        /// </param>
        /// <param name='fileContent'>
        /// File to upload.
        /// </param>
        /// <param name='fileName'>
        /// File name to upload. Name has to be spelled exactly as written here.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        public static async Task <System.IO.Stream> UploadFileAsync(this IFormdata operations, System.IO.Stream fileContent, string fileName, CancellationToken cancellationToken = default(CancellationToken))
        {
            var _result = await operations.UploadFileWithHttpMessagesAsync(fileContent, fileName, null, cancellationToken).ConfigureAwait(false);

            return(_result.Body);
        }
Пример #4
0
 /// <summary>
 /// Upload file
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='fileContent'>
 /// File to upload.
 /// </param>
 /// <param name='fileName'>
 /// File name to upload. Name has to be spelled exactly as written here.
 /// </param>
 public static Stream UploadFile(this IFormdata operations, Stream fileContent, string fileName)
 {
     return(operations.UploadFileAsync(fileContent, fileName).GetAwaiter().GetResult());
 }