//public static T AsPinataFile<T>(this T content, string remoteFilePath) where T : HttpContent //{ // var header = new ContentDispositionHeaderValue("form-data") // { // Name = "file", // FileName = remoteFilePath // }; // content.Headers.ContentDisposition = header; // return content; //} public static CapturedMultipartContent AddPinataFile(this CapturedMultipartContent multipart, HttpContent httpContent, string remoteFilePath) { var header = new ContentDispositionHeaderValue("form-data") { Name = "file", FileName = remoteFilePath }; httpContent.Headers.ContentDisposition = header; multipart.Add(httpContent); return(multipart); }
public async Task <Issue> CreateRepositoryIssueAttachmentAsync(string workspaceId, string repositorySlug, string issueId, IssueAttachment issueAttachment) { var capturedContent = new CapturedMultipartContent(); foreach (var propertyInfo in issueAttachment.GetType().GetProperties()) { capturedContent.Add(propertyInfo.Name, new StringContent(propertyInfo.GetValue(issueAttachment).ToString())); } var response = await GetIssuesUrl(workspaceId, repositorySlug, issueId) .PostMultipartAsync(content => content.AddStringParts(capturedContent)) .ConfigureAwait(false); return(await HandleResponseAsync <Issue>(response).ConfigureAwait(false)); }