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

How exactly is one meant to save a release asset? #369

Closed
Noxillio opened this issue Oct 13, 2023 · 5 comments
Closed

How exactly is one meant to save a release asset? #369

Noxillio opened this issue Oct 13, 2023 · 5 comments
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects

Comments

@Noxillio
Copy link

I'm able to get assets without a problem, and I am able to get an ArrayBuffer of an asset using the accepts: 'application/octet-stream' header, but no matter what I do I can't get it to save as a file. I am using TypeScript which further complicates the issue as the typing for the data property is either an object with static data, or simply null. It does not include the possibility of being an ArrayBuffer and so I can't work with it. I need advice please.

@ghost ghost added this to Inbox in JS Oct 13, 2023
@github-actions
Copy link
Contributor

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339 wolfy1339 added the Type: Support Any questions, information, or general needs around the SDK or GitHub APIs label Oct 13, 2023
@ghost ghost moved this from Inbox to Support in JS Oct 13, 2023
@wolfy1339
Copy link
Member

wolfy1339 commented Oct 14, 2023

You can override the type of the data property if needed.

As for how to save the file,

import { writeFile } from "node:fs/promises";

await writeFile("filename.ext", Buffer.from(data))

@Noxillio
Copy link
Author

Noxillio commented Oct 14, 2023

writeFile expects a callback and after putting one in I get an error:

src/index.ts:46:68 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type 'OctokitResponse<{ url: string; browser_download_url: string; id: number; node_id: string; name: string; label: string | null; state: "uploaded" | "open"; content_type: string; size: number; download_count: number; created_at: string; updated_at: string; uploader: { ...; } | null; }, 200>' is not assignable to parameter of type 'WithImplicitCoercion<string> | { [Symbol.toPrimitive](hint: "string"): string; }'.

The same thing happens with writeFileSync.

The problem is that the result doesn't include ArrayBuffer as a type. Nothing I do will overcome that issue, even if I use as ArrayBuffer (because that's what the result will be every time in my context).

@wolfy1339
Copy link
Member

Use as unknown as ArrayBuffer to forcefully override it

@kfcampbell
Copy link
Member

Closing as completed here, thanks @wolfy1339. Please feel free to reopen if there are further issues.

JS automation moved this from Support to Done Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects
Archived in project
JS
  
Done
Development

No branches or pull requests

3 participants