Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.

Commit

Permalink
Merge pull request #9 from apla/master
Browse files Browse the repository at this point in the history
now can upload multiple attachments at once
  • Loading branch information
floralvikings committed Aug 1, 2015
2 parents 5f8f59c + 644bd4e commit a374879
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions api/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,15 +836,15 @@ function IssueClient(jiraClient) {
};

/**
* Add an attachment to an issue.
* Add an attachments to an issue.
*
* @method addAttachment
* @memberOf IssueClient.js
* @param {Object} opts The options to pass to the API. Note that this object must contain EITHER an issueId or
* issueKey property; issueId will be used over issueKey if both are present.
* @param {string} [opts.issueId] The id of the issue. EX: 10002
* @param {string} [opts.issueKey] The Key of the issue. EX: JWR-3
* @param {string} opts.filename The file name of attachment.
* @param {string} opts.filename The file name of attachment. If you pass an array of filenames, multiple attachments will be added.
* @param callback Called when the attachment has been attached.
*/
this.addAttachment = function (opts, callback) {
Expand All @@ -853,7 +853,9 @@ function IssueClient(jiraClient) {
}
var options = this.buildRequestOptions(opts, '/attachments', 'POST');
delete options.body;
options.formData = {file: fs.createReadStream(opts.filename)};
if (opts.filename.constructor !== Array) opts.filename = [opts.filename];
var attachments = opts.filename.map (function (filename) {return fs.createReadStream(filename)});
options.formData = {file: attachments};
options.headers = {
"X-Atlassian-Token": "nocheck"
};
Expand Down

0 comments on commit a374879

Please sign in to comment.