/// <summary> /// Attach content to the specified issue /// See: https://docs.atlassian.com/jira/REST/latest/#d2e3035 /// </summary> /// <param name="jiraClient">IAttachmentDomain to bind the extension method to</param> /// <param name="issueKey">the key of the issue to attach to</param> /// <param name="content">the content can be anything what Dapplo.HttpExtensions supports</param> /// <param name="filename">Filename for the attachment</param> /// <param name="contentType">content-type for the attachment</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>Attachment</returns> public static async Task <Attachment> AttachAsync <TContent>(this IAttachmentDomain jiraClient, string issueKey, TContent content, string filename, string contentType = null, CancellationToken cancellationToken = default(CancellationToken)) where TContent : class { if (issueKey == null) { throw new ArgumentNullException(nameof(issueKey)); } if (content == null) { throw new ArgumentNullException(nameof(content)); } Log.Debug().WriteLine("Attaching to issue {0}", issueKey); var attachment = new AttachmentContainer <TContent> { Content = content, ContentType = contentType, FileName = filename }; jiraClient.Behaviour.MakeCurrent(); var attachUri = jiraClient.JiraRestUri.AppendSegments("issue", issueKey, "attachments"); var response = await attachUri.PostAsync <HttpResponse <IList <Attachment>, Error> >(attachment, cancellationToken).ConfigureAwait(false); // Return the attachment, should be only one! return(response.HandleErrors()[0]); }
/// <summary> /// Add an attachment to the specified content /// </summary> /// <typeparam name="TContent">The content to upload</typeparam> /// <param name="confluenceClient">IAttachmentDomain to bind the extension method to</param> /// <param name="contentId">content to add the attachment to</param> /// <param name="content">content of type TContent for the attachment</param> /// <param name="filename">Filename of the attachment</param> /// <param name="comment">Comment in the attachments information</param> /// <param name="contentType">Content-Type for the content, or null</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>Result with Attachment</returns> public static async Task <Result <Content> > AttachAsync <TContent>(this IAttachmentDomain confluenceClient, long contentId, TContent content, string filename, string comment = null, string contentType = null, CancellationToken cancellationToken = default) where TContent : class { var attachment = new AttachmentContainer <TContent> { Comment = comment, FileName = filename, Content = content, ContentType = contentType }; confluenceClient.Behaviour.MakeCurrent(); var postAttachmentUri = confluenceClient.ConfluenceApiUri.AppendSegments("content", contentId, "child", "attachment"); var response = await postAttachmentUri.PostAsync <HttpResponse <Result <Content>, Error> >(attachment, cancellationToken).ConfigureAwait(false); return(response.HandleErrors()); }
void ReleaseDesignerOutlets() { if (AttachmentContainer != null) { AttachmentContainer.Dispose(); AttachmentContainer = null; } if (AttachmentImage != null) { AttachmentImage.Dispose(); AttachmentImage = null; } if (BottomConstraint != null) { BottomConstraint.Dispose(); BottomConstraint = null; } if (DeleteButton != null) { DeleteButton.Dispose(); DeleteButton = null; } if (EditContainer != null) { EditContainer.Dispose(); EditContainer = null; } if (EditingBodyLabel != null) { EditingBodyLabel.Dispose(); EditingBodyLabel = null; } if (EditingCloseButton != null) { EditingCloseButton.Dispose(); EditingCloseButton = null; } if (EditingTitleLabel != null) { EditingTitleLabel.Dispose(); EditingTitleLabel = null; } if (ImageLoader != null) { ImageLoader.Dispose(); ImageLoader = null; } if (OpenCameraButton != null) { OpenCameraButton.Dispose(); OpenCameraButton = null; } if (OpenGalleryButton != null) { OpenGalleryButton.Dispose(); OpenGalleryButton = null; } if (PlaceholderLabel != null) { PlaceholderLabel.Dispose(); PlaceholderLabel = null; } if (SendButton != null) { SendButton.Dispose(); SendButton = null; } if (TextMaxHeightConstraint != null) { TextMaxHeightConstraint.Dispose(); TextMaxHeightConstraint = null; } if (TextView != null) { TextView.Dispose(); TextView = null; } }