adjusted header to fix download
This commit is contained in:
@@ -42,27 +42,36 @@ export default async function ApiProxy(req, res) {
|
||||
|
||||
var docRef = req.query;
|
||||
|
||||
console.log(docRef.id);
|
||||
|
||||
var queryUrl = "documents/download/" + docRef.id + "?hash=" + docRef.hash;
|
||||
|
||||
console.log(WEBAPI_URL + queryUrl);
|
||||
const configDocument = (access_token) => {
|
||||
return {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + access_token,
|
||||
},
|
||||
responseType: "arraybuffer",
|
||||
};
|
||||
};
|
||||
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL + queryUrl, // + hashAPIPath(queryUrl),
|
||||
azureHeadersPaged(token.access_token)
|
||||
configDocument(token.access_token)
|
||||
)
|
||||
.then((response) => {
|
||||
console.log(response.headers);
|
||||
res.status(200);
|
||||
res.setHeader(
|
||||
"Content-disposition",
|
||||
"content-disposition",
|
||||
"attachment; filename=" +
|
||||
response.headers["content-disposition"].split(
|
||||
"filename="
|
||||
)[1]
|
||||
);
|
||||
res.end(response.data);
|
||||
res.status(200).send(response.data);
|
||||
})
|
||||
.catch(({ err }) => {
|
||||
res.status(400).json(err);
|
||||
|
||||
Reference in New Issue
Block a user