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

addAttachmentOnIssue It only accepts Buffer, but I would like Stream #2

Open
Batyodie opened this issue Mar 31, 2024 · 1 comment
Open

Comments

@Batyodie
Copy link
Contributor

The method for adding files to issue only accepts a buffer, this is not very convenient, I want to get a preview of the file in jira and its type, but it turns out that I won't be able to send it.

  /** Add attachment to a Issue
   * [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#api/2/issue/{issueIdOrKey}/attachments-addAttachment)
   * @param issueId - issue id
   * @param readStream - readStream object from fs
   */
  addAttachmentOnIssue(issueId: string, readStream: Buffer) {
    const formData = new FormData();
    formData.append("file", new Blob([readStream], { type: "application/octet-stream" }));
    return this.doRequest<unknown>(
      this.makeRequestHeader(
        this.makeUri({
          pathname: `/issue/${issueId}/attachments`,
        }),
        {
          method: "POST",
          headers: {
            "X-Atlassian-Token": "nocheck",
          },
          data: formData,
        },
      ),
    );
  }

In the classic version of the library it is possible to send streams, as far as I know, this is due to the fact that they use postman instead of axios.

Снимок экрана 2024-03-31 в 14 03 36

For me, the most important thing is that you can transfer the name and type of the file.

@Aeolun
Copy link
Owner

Aeolun commented Jul 10, 2024

@Batyodie New version should have two extra parameters that take both mimeType and fileName, which I think do what you want.

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

No branches or pull requests

2 participants