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

🚧Fix wrong media content issue #70

Merged
merged 2 commits into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions GitHubClients/ReleaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,16 +489,23 @@ export class ReleaseClient extends GitHubClient {

const url = `https://api.github.com/repos/${this.ownerName}/${this.repoName}/releases/assets/${assetId}`;

// Get the current accept header to set it back after the download
const acceptHeader = this.getHeader("Accept") ?? "";

// Change the default 'Accept' header from 'application/vnd.github+json' to 'application/octet-stream'
// This is required for download as a file
this.updateOrAddHeader("Accept", "application/octet-stream");

const response = await this.requestGET(url);

// Reset the `Accept` header back to the original value
this.updateOrAddHeader("Accept", acceptHeader);

if (response.status === GitHubHttpStatusCodes.Unauthorized) {
throw new AuthError();
} else if (response.status !== GitHubHttpStatusCodes.OK) {
const errorMsg = `The asset with the id '${assetId}' could not be downloaded.`;

throw new ReleaseError(errorMsg);
}

Expand Down
Loading