/// <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); }
/// <summary> /// Deletes an image /// </summary> /// <param name="deleteID">If this image belongs to the account, the ID, if not, the deletehash</param> /// <returns>An ImgurBasic response</returns> public async Task <ImgurBasic> DeleteImageAsync(String deleteID) { String responseString = await DeleteImgurDataAsync(ImgurEndpoints.Image(deleteID)); return(await JsonConvert.DeserializeObjectAsync <ImgurBasic>(responseString, _defaultSerializerSettings)); }
/// <summary> /// Fills in an ImgurImage object with details for a specific image. Requires an ImageID. /// </summary> /// <param name="imageID">The Imgur image ID of the image you want details for.</param> /// <returns>A nicely filled in ImgurImage object. All for you.</returns> public async Task <ImgurImage> GetImageDetailsAsync(String imageID) { String responseString = await GetAnonymousImgurDataAsync(ImgurEndpoints.Image(imageID)); return((await JsonConvert.DeserializeObjectAsync <ImgurBasicWithImage>(responseString)).Image); }