Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Attachments #137

Closed
3 tasks
lipkau opened this issue Jun 16, 2017 · 11 comments · Fixed by #198
Closed
3 tasks

Feature Attachments #137

lipkau opened this issue Jun 16, 2017 · 11 comments · Fixed by #198

Comments

@lipkau
Copy link
Member

lipkau commented Jun 16, 2017

api/2/attachment

Add Attahment

Parameter

  • -Issue int / PSJira.Issue mandatory
  • -FilePath string / FileInfo mandatory

Helpful links

Output

PSJira.Attachment

Get an Attachment from an Issue

  • PSJira.Issue should have the property Attachment of type PSJira.Attachment

Remove an Attachment

Parameter

  • -Id integer / PSJira.Attachement mandatory - ValueFromPipeline, ValueFromPipelineByPropertyName

Output

Boolean

@beaudryj
Copy link
Contributor

thanks for making that quick :)

@lipkau
Copy link
Member Author

lipkau commented Jun 16, 2017

please note: any contribution is welcome. Not all listed APIs/functions must be implemented at the same time.
This issue will track the development of the features

@tehfonz
Copy link

tehfonz commented Sep 21, 2017

function Upload-JiraCSV($jiraTicket, $filepath)`
{
    $wc = new-object System.Net.WebClient
    $wc.Headers.Add("Authorization", $basicAuthValue)
    $wc.Headers.Add("X-Atlassian-Token", "no-check")
    $wc.Headers.Add("Content-Type","multipart")
    $wc.UploadFile("http://<URL>/rest/api/2/issue/$jiraTicket/attachments", $(Resolve-Path $filepath))
}
Upload-JiraCSV <ISSUE-KEY> <direct file path> | Out-Null
$user = '<username>'
$pass = '<password>'
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"

@swatkris
Copy link

@lipkau,
Hello Oliver,
could you please post a sample how to use of "Add-JiraAttachment".
Sorry.
Thank you
SWATKRIS

@lipkau
Copy link
Member Author

lipkau commented Oct 12, 2017

Add-JiraAttachment -Issue 'FOO-1234' -FilePath 'C:\file.txt'

@swatkris
Copy link

@lipkau,
Thank you very much, but for Add-JiraIssueComment there is also a file with .ps1. But for Add-JiraAttachment... I can´t find anyone... is it right ? Where should it be ?
Thanks agein
Yours
swatkris

@lipkau
Copy link
Member Author

lipkau commented Oct 12, 2017

No.
This ticket is requesting the function to be written

@dhegland
Copy link

:) Thanks Oliver, looking forward to having this feature, need help developing it? :)

@lipkau
Copy link
Member Author

lipkau commented Oct 12, 2017

Yes. That's what the up-for-grabs label is for :-D

@aaronsb
Copy link

aaronsb commented Oct 12, 2017

I would suggest taking a look at this super helpful post on multi part uploads:

http://blog.majcica.com/2016/01/13/powershell-tips-and-tricks-multipartform-data-requests/

Author wrote a Invoke-MultipartFormDataUpload function which appears to fulfill the rest api's requirement for rfc 1867 content format.

I think this would fit best as an appendex to Invoke-JiraMethod, since that itself is a wrapper for Invoke-WebRequest.

The Invoke-MultipartFormDataUpload would appear to suppliment the base function of iwr, so it would make sense that the jira specific wrapper for iwr would have this capability to enhance iwr (within the wrapper)

From there, several different type of "helpers" to feed invoke-webrequest with the multipart method could be written for file uploads and avatars for jira. Confluence/PS would benefit from this same enhancement.

@lipkau
Copy link
Member Author

lipkau commented Oct 16, 2017

@beaudryj already has some working code.
waiting on him to submit a PR :-)

@lipkau lipkau added this to the v2.4 milestone Oct 23, 2017
@lipkau lipkau mentioned this issue Nov 1, 2017
@ghost ghost assigned lipkau Nov 1, 2017
@ghost ghost added Status:In Review and removed Status:Ready labels Nov 1, 2017
lipkau added a commit that referenced this issue Nov 1, 2017
FEATURES:
  - `Add-JiraIssueAttachment`: Add an attachment to an issue (#137, [@beaudryj][])
  - `Get-JiraIssueAttachment`: Get attachments from issues (#137, [@beaudryj][])
  - `Remove-JiraIssueAttachment`: Remove attachments from issues (#137, [@beaudryj][])

IMPROVEMENTS:
  - `JiraPS.Issue` now has a property for Attachments `JiraPS.Attachment` (#137, [@beaudryj][])
@ghost ghost removed the Status:In Review label Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants