From be9cefb8d6f2b61179cd3c83d3c1dbf67d69295f Mon Sep 17 00:00:00 2001 From: Daniel Schlachter Date: Fri, 1 Mar 2024 11:29:47 +0100 Subject: [PATCH] add mimeTypes to sample attachments --- xmpls/attachments/db/init.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/xmpls/attachments/db/init.js b/xmpls/attachments/db/init.js index 9d9e01e..a6e2501 100644 --- a/xmpls/attachments/db/init.js +++ b/xmpls/attachments/db/init.js @@ -1,7 +1,7 @@ const cds = require('@sap/cds/lib') module.exports = async function () { - // this ensures customers are in the db + // this ensures customers are in the db already cds.once('served', async () => { const { 'sap.capire.incidents.Customers': Customers } = cds.model.entities await UPDATE (Customers) .set ('avatar_ID = ID') @@ -13,13 +13,13 @@ module.exports = async function () { const { 'sap.capire.incidents.Incidents.attachments': Attachments } = cds.model.entities await attachments.put (Attachments, [ - [ '3b23bb4b-4ac7-4a24-ac02-aa10cabd842c', 'INVERTER FAULT REPORT.pdf' ], - [ '3b23bb4b-4ac7-4a24-ac02-aa10cabd842c', 'Inverter-error-logs.txt' ], - [ '3a4ede72-244a-4f5f-8efa-b17e032d01ee', 'No_Current.xlsx' ], - [ '3ccf474c-3881-44b7-99fb-59a2a4668418', 'strange-noise.csv' ], - [ '3583f982-d7df-4aad-ab26-301d4a157cd7', 'Broken Solar Panel.jpg' ] - ].map(([ up__ID, filename ]) => ({ - up__ID, filename, + [ '3b23bb4b-4ac7-4a24-ac02-aa10cabd842c', 'INVERTER FAULT REPORT.pdf', 'application/pdf' ], + [ '3b23bb4b-4ac7-4a24-ac02-aa10cabd842c', 'Inverter-error-logs.txt', 'application/txt' ], + [ '3a4ede72-244a-4f5f-8efa-b17e032d01ee', 'No_Current.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ], + [ '3ccf474c-3881-44b7-99fb-59a2a4668418', 'strange-noise.csv', 'text/csv' ], + [ '3583f982-d7df-4aad-ab26-301d4a157cd7', 'Broken Solar Panel.jpg', 'image/jpeg' ] + ].map(([ up__ID, filename, mimeType ]) => ({ + up__ID, filename, mimeType, content: createReadStream (join(__dirname, 'content', filename)), createdAt: new Date (Date.now() - Math.random() * 30*24*60*60*1000), createdBy: 'alice', @@ -29,11 +29,10 @@ module.exports = async function () { await attachments.put (Images, [ [ '1004155', 'Daniel Watts.png' ], [ '1004161', 'Stormy Weathers.png' ], - [ '1004100', 'Sunny Sunshine.png' ], + [ '1004100', 'Sunny Sunshine.png' ] ].map(([ ID, filename ]) => ({ ID, filename, content: createReadStream (join(__dirname, 'content', filename)), }))) - -} +} \ No newline at end of file