mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
27 lines
630 B
TypeScript
27 lines
630 B
TypeScript
import { Inject, Service } from 'typedi';
|
|
import HasTenancyService from '../Tenancy/TenancyService';
|
|
|
|
@Service()
|
|
export class UploadDocument {
|
|
@Inject()
|
|
private tenancy: HasTenancyService;
|
|
|
|
/**
|
|
* Inserts the document metadata.
|
|
* @param {number} tenantId
|
|
* @param {} file
|
|
* @returns {}
|
|
*/
|
|
async upload(tenantId: number, file: any) {
|
|
const { Document } = this.tenancy.models(tenantId);
|
|
|
|
const insertedDocument = await Document.query().insert({
|
|
key: file.key,
|
|
mimeType: file.mimetype,
|
|
size: file.size,
|
|
originName: file.originalname,
|
|
});
|
|
return insertedDocument;
|
|
}
|
|
}
|