-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscanFile.js
More file actions
24 lines (18 loc) · 818 Bytes
/
scanFile.js
File metadata and controls
24 lines (18 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const functions = require('firebase-functions');
const config = require('../shared/config');
const { firebase } = require('../shared/admin.js');
const { scanFile } = require('../actions/malware-scanning/scanFile')(config, firebase);
module.exports = functions.region('europe-west2').https.onCall(async (data, context) => {
// authenticate the request
if (!context.auth) {
throw new functions.https.HttpsError('failed-precondition', 'The function must be called while authenticated.');
}
// validate input parameters
if (!(typeof data.fileURL === 'string') || data.fileURL.length === 0) {
throw new functions.https.HttpsError('invalid-argument', 'Please specify a fileURL');
}
// run the virus scan
const result = await scanFile(data.fileURL);
// return the outcome
return result;
});