Generate array buffer for binary (#4075)
This commit is contained in:
parent
a512cf46eb
commit
c37280b8cb
3 changed files with 19 additions and 7 deletions
|
@ -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";
|
||||
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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>({
|
||||
|
|
Loading…
Reference in a new issue