Imgur.API.Endpoints.Impl.ImageEndpoint.UploadImageStreamAsync C# (CSharp) Метод

UploadImageStreamAsync() публичный Метод

Upload a new image using a stream.
/// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// Thrown when an error is found in a response from an Imgur endpoint. Thrown when an error is found in a response from a Mashape endpoint.
public UploadImageStreamAsync ( Stream image, string albumId = null, string title = null, string description = null ) : Task
image Stream A stream.
albumId string /// The id of the album you want to add the image to. For anonymous albums, {albumId} should be the /// deletehash that is returned at creation. ///
title string The title of the image.
description string The description of the image.
Результат Task
        public async Task<IImage> UploadImageStreamAsync(Stream image, string albumId = null, string title = null,
            string description = null)
        {
            if (image == null)
                throw new ArgumentNullException(nameof(image));

            var url = "image";

            using (var request = RequestBuilder.UploadImageStreamRequest(url, image, albumId, title, description))
            {
                var returnImage = await SendRequestAsync<Image>(request).ConfigureAwait(false);
                return returnImage;
            }
        }

Usage Example

Пример #1
0
        public async Task UploadImageStreamAsync_WithImage_AreEqual()
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new ImageEndpoint(client);
            IImage image = null;

            using (var fs = new FileStream("banana.gif", FileMode.Open))
            {
                image = await endpoint.UploadImageStreamAsync(fs, null, "stream test title!", "stream test desc!");
            }

            Assert.IsFalse(string.IsNullOrEmpty(image.Id));
            Assert.AreEqual("stream test title!", image.Title);
            Assert.AreEqual("stream test desc!", image.Description);

            await GetImageAsync_WithImage_AreEqual(image);
            await UpdateImageAsync_WithImage_AreEqual(image);
            await DeleteImageAsync_WithImage_IsTrue(image);
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.ImageEndpoint::UploadImageStreamAsync