Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion webapp/api/routes/report/check-your-answers.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ export default function (app) {
for (const prop in sd['property']) {
if (sd['property'].hasOwnProperty(prop)) {
const innerObj = sd['property'][prop];
const uploadsPath = '../../../uploads/';
console.log(`Resolving wreck material file path for '${__dirname}' '${uploadsPath}' '${innerObj.image}'`);
const filePath = path.resolve(
__dirname,
'../../../uploads/',
uploadsPath,
innerObj.image
);
console.log(`Wreck material file path is ${filePath}`);

try {
const imageData = await fs.promises.readFile(filePath, 'base64');
Expand All @@ -117,6 +120,8 @@ export default function (app) {
data['wreck-materials'].push(innerObj);
} catch (error) {
console.error('Error reading file:', error);
console.error('Full file read error object:', JSON.stringify(error));
// Todo: If it didn't manage to read the image file, the post to the API will fail. We need to decide how we want to handle this possibility
data['wreck-materials'].push(innerObj);
}
}
Expand Down
Loading