mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
Fix download software installer path (#21255)
Co-authored-by: gillespi314 <73313222+gillespi314@users.noreply.github.com>
This commit is contained in:
parent
07314c8d04
commit
c1c5c77dfc
6 changed files with 26 additions and 2 deletions
1
changes/21251-bugfix-download-software-installer
Normal file
1
changes/21251-bugfix-download-software-installer
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Fixed a bug where the wrong API path was used to download a software installer.
|
||||
|
|
@ -5,6 +5,7 @@ import React, {
|
|||
useState,
|
||||
} from "react";
|
||||
import FileSaver from "file-saver";
|
||||
import { parse } from "content-disposition";
|
||||
|
||||
import PATHS from "router/paths";
|
||||
import { AppContext } from "context/app";
|
||||
|
|
@ -263,7 +264,21 @@ const SoftwarePackageCard = ({
|
|||
`Byte size (${resp.data.size}) does not match content-length header (${contentLength})`
|
||||
);
|
||||
}
|
||||
const filename = name;
|
||||
|
||||
let filename = name;
|
||||
try {
|
||||
const cd = parse(resp.headers["content-disposition"]);
|
||||
if (cd.parameters.filename) {
|
||||
filename = cd.parameters.filename;
|
||||
}
|
||||
} catch (e) {
|
||||
// TODO: Refactor this component's props so we can derive a file extension from the `source`
|
||||
// property from title detail response.
|
||||
//
|
||||
// For now, we'll just use the software name prop as the filename if we can't parse the
|
||||
// content-disposition header.
|
||||
}
|
||||
|
||||
const file = new File([resp.data], filename, {
|
||||
type: "application/octet-stream",
|
||||
});
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ export default {
|
|||
`/${API_VERSION}/fleet/software/versions/${id}`,
|
||||
SOFTWARE_PACKAGE_ADD: `/${API_VERSION}/fleet/software/package`,
|
||||
SOFTWARE_PACKAGE: (id: number) =>
|
||||
`/${API_VERSION}/fleet/software/${id}/package`,
|
||||
`/${API_VERSION}/fleet/software/titles/${id}/package`,
|
||||
SOFTWARE_INSTALL_RESULTS: (uuid: string) =>
|
||||
`/${API_VERSION}/fleet/software/install/results/${uuid}`,
|
||||
SOFTWARE_PACKAGE_INSTALL: (id: number) =>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
"@types/dompurify": "3.0.2",
|
||||
"ace-builds": "1.4.12",
|
||||
"axios": "1.6.0",
|
||||
"content-disposition": "0.5.4",
|
||||
"core-js": "3.25.1",
|
||||
"date-fns": "3.6.0",
|
||||
"date-fns-tz": "3.1.3",
|
||||
|
|
@ -99,6 +100,7 @@
|
|||
"@tsconfig/recommended": "1.0.1",
|
||||
"@types/chrome": "0.0.237",
|
||||
"@types/classnames": "0.0.32",
|
||||
"@types/content-disposition": "0.5.4",
|
||||
"@types/expect": "1.20.3",
|
||||
"@types/file-saver": "2.0.5",
|
||||
"@types/jest": "29.5.12",
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ const config = {
|
|||
resolve: {
|
||||
extensions: [".tsx", ".ts", ".js", ".jsx", ".json"],
|
||||
modules: [path.resolve(path.join(repo, "./frontend")), "node_modules"],
|
||||
fallback: { path: require.resolve("path-browserify") },
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4869,6 +4869,11 @@
|
|||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/content-disposition@0.5.4":
|
||||
version "0.5.4"
|
||||
resolved "https://registry.yarnpkg.com/@types/content-disposition/-/content-disposition-0.5.4.tgz#de48cf01c79c9f1560bcfd8ae43217ab028657f8"
|
||||
integrity sha512-0mPF08jn9zYI0n0Q/Pnz7C4kThdSt+6LD4amsrYDDpgBfrVWa3TcCOxKX1zkGgYniGagRv8heN2cbh+CAn+uuQ==
|
||||
|
||||
"@types/cookie@^0.4.1":
|
||||
version "0.4.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.1.tgz#bfd02c1f2224567676c1545199f87c3a861d878d"
|
||||
|
|
|
|||
Loading…
Reference in a new issue