/// <summary> /// Upload a new image. /// </summary> /// <param name="ImageToUploadFileData">A Byte array representing the image</param> /// <param name="Title">The title of the image</param> /// <param name="Description"> The description of the image</param> /// <param name="Album">The id of the album you want to add the image to. For anonymous albums, {album} should be the deletehash that is returned at creation.</param> /// <returns>A ImgurImage object that represents the image just uploaded</returns> public async Task <ImgurImage> PostImageAnonymousAsync(Byte[] ImageToUploadFileData, String Title = "", String Description = "", String Album = "") { // TODO: Make all the strings used in form content constants somewhere MultipartFormDataContent content = new MultipartFormDataContent(BoundaryGuid.ToString()); content.Add(new ByteArrayContent(ImageToUploadFileData), ImgurEndpoints.ImageEndpointParameterLookup[ImageEndpointParameters.image]); if (Title != "") { content.Add(new StringContent(Title), ImgurEndpoints.ImageEndpointParameterLookup[ImageEndpointParameters.title]); } if (Description != "") { content.Add(new StringContent(Description), ImgurEndpoints.ImageEndpointParameterLookup[ImageEndpointParameters.description]); } if (Album != "") { content.Add(new StringContent(Album), ImgurEndpoints.ImageEndpointParameterLookup[ImageEndpointParameters.album]); } String responseString = await PostAnonymousImgurDataAsync(ImgurEndpoints.Image(), content); ImgurBasicWithImage returnedImage = await JsonConvert.DeserializeObjectAsync <ImgurBasicWithImage>(responseString, _defaultSerializerSettings); return(returnedImage.Image); }
/// <summary> /// Upload a new image. /// </summary> /// <param name="url">The url to an image to upload</param> /// <param name="Title">The title of the image</param> /// <param name="Description"> The description of the image</param> /// <param name="Album">The id of the album you want to add the image to. For anonymous albums, {album} should be the deletehash that is returned at creation.</param> /// <returns>A ImgurImage object that represents the image just uploaded</returns> public async Task <ImgurImage> PostImageAnonymousAsync(String url, String Title = "", String Description = "", String Album = "") { MultipartFormDataContent content = new MultipartFormDataContent(BoundaryGuid.ToString()); content.Add(new StringContent(url), ImgurEndpoints.ImageEndpointParameterLookup[ImageEndpointParameters.image]); if (Title != "") { content.Add(new StringContent(Title), ImgurEndpoints.ImageEndpointParameterLookup[ImageEndpointParameters.title]); } if (Description != "") { content.Add(new StringContent(Description), ImgurEndpoints.ImageEndpointParameterLookup[ImageEndpointParameters.description]); } if (Album != "") { content.Add(new StringContent(Album), ImgurEndpoints.ImageEndpointParameterLookup[ImageEndpointParameters.album]); } String responseString = await PostAnonymousImgurDataAsync(ImgurEndpoints.Image(), content); ImgurBasicWithImage returnedImage = await JsonConvert.DeserializeObjectAsync <ImgurBasicWithImage>(responseString, _defaultSerializerSettings); return(returnedImage.Image); }