dobo
Version:
Database ORM/ODM for Bajo Framework
17 lines (14 loc) • 512 B
JavaScript
async function mergeAttachmentInfo (rec, source, { mimeType, stats, fullPath }) {
const { importPkg } = this.app.bajo
const { fs } = this.lib
const { pick } = this.lib._
if (!this.app.waibu) return
const mime = await importPkg('waibu:mime')
if (mimeType) rec.mimeType = mime.getType(rec.file)
if (fullPath) rec.fullPath = source
if (stats) {
const s = fs.statSync(source)
rec.stats = pick(s, ['size', 'atime', 'ctime', 'mtime'])
}
}
export default mergeAttachmentInfo