Generate array buffer for binary (#4075)

This commit is contained in:
Erik Jan de Wit 2023-01-02 06:38:10 -05:00 committed by GitHub
parent a512cf46eb
commit c37280b8cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 7 deletions

View file

@ -1,5 +1,5 @@
import { useTranslation } from "react-i18next";
import { FormProvider, useForm } from "react-hook-form";
import { FormProvider, useForm } from "react-hook-form-v7";
import { Button, Modal, Form } from "@patternfly/react-core";
import { saveAs } from "file-saver";

View file

@ -226,10 +226,6 @@ export class Agent {
url.search = stringifyQueryParams(searchParams);
if (!requestHeaders.has("content-type")) {
requestHeaders.set("content-type", "application/x-www-form-urlencoded");
}
try {
const res = await fetchWithError(url, {
...requestOptions,
@ -263,6 +259,16 @@ export class Agent {
return { [field]: resourceId };
}
if (
Object.entries(headers || []).find(
([key, value]) =>
key.toLowerCase() === "accept" &&
value === "application/octet-stream"
)
) {
return res.arrayBuffer();
}
return parseResponse(res);
} catch (err) {
if (

View file

@ -956,21 +956,27 @@ export class Clients extends Resource<{ realm?: string }> {
public downloadKey = this.makeUpdateRequest<
{ id: string; attr: string },
KeyStoreConfig,
string
ArrayBuffer
>({
method: "POST",
path: "/{id}/certificates/{attr}/download",
urlParamKeys: ["id", "attr"],
headers: {
accept: "application/octet-stream",
},
});
public generateAndDownloadKey = this.makeUpdateRequest<
{ id: string; attr: string },
KeyStoreConfig,
string
ArrayBuffer
>({
method: "POST",
path: "/{id}/certificates/{attr}/generate-and-download",
urlParamKeys: ["id", "attr"],
headers: {
accept: "application/octet-stream",
},
});
public uploadKey = this.makeUpdateRequest<{ id: string; attr: string }, any>({