Files in the tmp directory are emptied everyday, tmp directory lives @:
/app/tmp
where app is the root directory
To download files from it you can read the file and convert it into a base 64 and send it back to the client as a data URL:
Server:
let filePath = path.join(__dirname, '..', '..', 'tmp', fileName);
fs.readFile(filePath, {encoding: 'base64'}, function (err, data) {
if (!err) {
let returnData = `data:${mimeType};base64,` + data;
res.json({fileName: fileName, displayName: displayName, base64: returnData})
} else {
console.log(err);
}
});
Client side:
function b64toBlob(dataURI) {
var byteString = atob(dataURI.split(',')[1]);
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ab], { type: 'image/jpeg' });
}
var blob = b64toBlob(res.data.base64);
var blobUrl = URL.createObjectURL(blob);
var link = document.createElement("a"); // Or maybe get it from the current document
link.href = blobUrl;
link.download = res.data.displayName;
document.body.appendChild(link)
link.click()