Skip to content

TypeScript: How to set the data parameter to Buffer #2087

Answered by retorquere
retorquere asked this question in Q&A
Discussion options

You must be logged in to vote

It looks like the data parameter to uploadReleaseAsset must be string | Buffer, not string, but I don't know where the code lives so I can't put together a PR. For the time being, this works:

await octokit.repos.uploadReleaseAsset({
      owner,
      repo,
      url: release.data.upload_url,
      release_id: release.data.id,
      data: (fs.readFileSync(asset) as unknown as string), // fool octokit into accepting the Buffer
      headers: {
        'content-type': contentType,
        'content-length': fs.statSync(asset).size,
      },
      name,
    })

Replies: 7 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by gr2m
Comment options

You must be logged in to vote
1 reply
@jan-auer
Comment options

Comment options

You must be logged in to vote
0 replies

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment options

You must be logged in to vote
1 reply
@davidwinter
Comment options

Comment options

You must be logged in to vote
2 replies
@gr2m
Comment options

@gr2m
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants
Converted from issue

This discussion was converted from issue #2086 on April 22, 2021 18:54.