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

support uploading attachments to jira tickets #313

Open
efreethy opened this issue Dec 3, 2020 · 3 comments
Open

support uploading attachments to jira tickets #313

efreethy opened this issue Dec 3, 2020 · 3 comments

Comments

@efreethy
Copy link

efreethy commented Dec 3, 2020

No description provided.

@asharpe
Copy link

asharpe commented Dec 14, 2022

@randyho-kk that's the wrong API :) This library uses v2 of the JIRA api.

I'd also really like the ability add an attachment, and a method exists for (addAttachementToIssue - https://github.com/jira-node/node-jira-client/blob/master/src/jira.js#L1559).

Unfortunately I don't have the file on the FS (and I don't intend to put it there) and I can't get it work by turning a string into a stream, eg.

Readable = require('stream').Readable
...
# standard Jira setup, known to work because I do a bunch of other stuff just fine
...
var message = 'this should work :(';
Jira.addAttachmentOnIssue(issue.id, Readable.from(message));

This gets me a 500 error from the server due to EOF

java.lang.RuntimeException: org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly

Followed by a standard java stack trace, not so useful in this context. I'm on a version of node where this should work

# node --version
v16.18.1

FWIW in another project I have successfully added attachments using the servicedesk API (/rest/servicedeskapi/request/#{id}/attachment), but I built the request myself - I'd like to avoid that if possible.

Edit: this actually works if you use fs.getReadStream('/path/to/file'); so there's something different about this stream than that created by Readable.from :(

@asharpe
Copy link

asharpe commented Dec 14, 2022

Solved by adding a path property to the created stream which appears to be used as the filename of the attachment in JIRA.

Readable = require('stream').Readable
...
# standard Jira setup
...
var message = 'this now works, yay, and :(';
var stream = Readable.from(message);
stream.path = 'file-name-in-jira.ext';
Jira.addAttachmentOnIssue(issue.id, stream);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants