Example #1
0
        /// <summary>
        ///     Upload a new image using a URL.
        /// </summary>
        /// <param name="upload">The Stream file of the image/video.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="fileType">The Filetype (image/video).</param>
        /// <param name="albumId">
        ///     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.
        /// </param>
        /// <param name="name">The name of the file.</param>
        /// <param name="title">The title of the image.</param>
        /// <param name="description">The description of the image.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception>
        /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception>
        /// <returns></returns>
        private async ValueTask <IImage> UploadFileInternalAsync(Stream upload, string fileName, FileType fileType = FileType.Image, string albumId = null, string name = null, string title = null, string description = null)
        {
            const string url = nameof(upload);

            using (var request = ImageRequestBuilder.UploadFileRequest(url, upload, fileName, fileType, albumId, name, title, description))
            {
                var returnImage = await SendRequestAsync <Image>(request).ConfigureAwait(false);

                return(returnImage);
            }
        }