refactor(actions): fix document download helper contract
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import axios from "axios";
|
|
||||||
import { BASE_URL } from "../core/env";
|
import { BASE_URL } from "../core/env";
|
||||||
import { consoleLogger } from "../core/logger";
|
import { consoleLogger } from "../core/logger";
|
||||||
import { hashAPIPath } from "../core/hash";
|
import { hashAPIPath } from "../core/hash";
|
||||||
@@ -334,26 +333,20 @@ export const deleteRepBlob = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const downloadBlob = (containerName, blobName) => {
|
export const downloadBlob = (containerName, blobName) => {
|
||||||
return axios
|
const queryUrl =
|
||||||
.get(
|
BASE_URL +
|
||||||
BASE_URL +
|
"/api/file/downloadblob?container=" +
|
||||||
"/api/file/downloadblob?container=" +
|
containerName.toLowerCase() +
|
||||||
containerName.toLowerCase() +
|
"&blobname=" +
|
||||||
"&blobname=" +
|
blobName;
|
||||||
blobName,
|
|
||||||
{ responseType: "blob" }
|
|
||||||
)
|
|
||||||
.then((response) => {
|
|
||||||
res.setHeader(
|
|
||||||
"content-disposition",
|
|
||||||
"attachment; filename=" + blobName
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).send(response.data);
|
return requestJson({
|
||||||
})
|
method: "get",
|
||||||
.catch((error) => {
|
url: queryUrl,
|
||||||
consoleLogger(error);
|
responseType: "blob"
|
||||||
});
|
}).catch((error) => {
|
||||||
|
consoleLogger(error);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getProgressFromBlob = async (containerName, casereference) => {
|
export const getProgressFromBlob = async (containerName, casereference) => {
|
||||||
|
|||||||
@@ -1991,3 +1991,31 @@ Validation:
|
|||||||
Follow-ups:
|
Follow-ups:
|
||||||
|
|
||||||
- Optional next bounded slice: isolate and correct `downloadBlob` behavior in `documentDirectService` (including legacy `res` usage) behind an explicit, tested contract.
|
- Optional next bounded slice: isolate and correct `downloadBlob` behavior in `documentDirectService` (including legacy `res` usage) behind an explicit, tested contract.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### CL-056: TASK22260 next slice — document direct service download helper contract fix
|
||||||
|
|
||||||
|
date: 2026-03-25
|
||||||
|
author: Cline
|
||||||
|
scope: `actions/services/documentDirectService.js`
|
||||||
|
type: change
|
||||||
|
rationale: Execute the next bounded follow-up by correcting the legacy `downloadBlob` service helper path that still relied on invalid `res` references and direct axios usage, aligning it to shared request client behavior.
|
||||||
|
impact: Fixes a service-layer contract defect risk in document download helper and improves consistency by using shared request client patterns; no endpoint contract change.
|
||||||
|
status: completed
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
|
||||||
|
- Refactored `downloadBlob(containerName, blobName)` in `documentDirectService`:
|
||||||
|
- removed legacy direct `axios.get(...).then(response => res.status(...))` pattern that referenced undefined `res` in service layer
|
||||||
|
- now returns blob response data via `requestJson({ method: "get", url, responseType: "blob" })`
|
||||||
|
- preserved catch-path logging (`consoleLogger`)
|
||||||
|
- Removed now-unused module-level `axios` import from `documentDirectService`.
|
||||||
|
|
||||||
|
Validation:
|
||||||
|
|
||||||
|
- `npm run lint` -> warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors)
|
||||||
|
|
||||||
|
Follow-ups:
|
||||||
|
|
||||||
|
- Optional next bounded slice: add a focused test (or integration harness assertion) around `downloadBlob` service return contract to prevent regression to response-object assumptions.
|
||||||
|
|||||||
Reference in New Issue
Block a user