blob: 93c3a63031696c13e914e0725d2cbdbe3d52c5bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import DriveFile, { pack } from '../../../../../models/drive-file';
/**
* Show a file
*/
module.exports = async (params, user) => {
// Get 'fileId' parameter
const [fileId, fileIdErr] = $(params.fileId).type(ID).$;
if (fileIdErr) throw 'invalid fileId param';
// Fetch file
const file = await DriveFile
.findOne({
_id: fileId,
'metadata.userId': user._id
});
if (file === null) {
throw 'file-not-found';
}
// Serialize
const _file = await pack(file, {
detail: true
});
return _file;
};
|