@@ -28,49 +28,24 @@ export class IssueAttachments {
2828 * to view the issue.
2929 * - If attachments are added in private comments, the comment-level restriction will be applied.
3030 */
31- async getAttachmentContent < T = Buffer > (
32- parameters : Parameters . GetAttachmentContent | string ,
33- callback : Callback < T > ,
34- ) : Promise < void > ;
35- /**
36- * Returns the contents of an attachment. A `Range` header can be set to define a range of bytes within the attachment
37- * to download. See the [HTTP Range header standard](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range)
38- * for details.
39- *
40- * To return a thumbnail of the attachment, use [Get attachment
41- * thumbnail](#api-rest-api-2-attachment-thumbnail-id-get).
42- *
43- * This operation can be accessed anonymously.
44- *
45- * **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** For the
46- * issue containing the attachment:
47- *
48- * - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is
49- * in.
50- * - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
51- * to view the issue.
52- * - If attachments are added in private comments, the comment-level restriction will be applied.
53- */
54- async getAttachmentContent < T = Buffer > (
55- parameters : Parameters . GetAttachmentContent | string ,
56- callback ?: never ,
57- ) : Promise < T > ;
58- async getAttachmentContent < T = Buffer > (
59- parameters : Parameters . GetAttachmentContent | string ,
60- callback ?: Callback < T > ,
61- ) : Promise < void | T > {
62- const id = typeof parameters === 'string' ? parameters : parameters . id ;
63-
31+ async getAttachmentContent < T = Models . AttachmentContent > (
32+ parameters : Parameters . GetAttachmentContent ,
33+ ) : Promise < T > {
34+ // todo add Range header
6435 const config : Request = {
65- url : `/rest/api/2/attachment/content/${ id } ` ,
36+ url : `/rest/api/2/attachment/content/${ parameters . id } ` ,
6637 method : 'GET' ,
6738 query : {
68- redirect : typeof parameters !== 'string' && parameters . redirect ,
39+ redirect : parameters . redirect ,
6940 } ,
70- // responseType: 'arraybuffer', // todo
7141 } ;
7242
73- return this . client . sendRequest ( config ) ;
43+ const response = await this . client . sendRequestWithRawResponse ( config ) ;
44+
45+ const contentType = response . headers . get ( 'content-type' ) ;
46+ const content = await response . arrayBuffer ( ) ;
47+
48+ return { contentType, content } as T ;
7449 }
7550
7651 /**
0 commit comments