mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
fix: TS types
This commit is contained in:
@@ -6,6 +6,7 @@ import { AttachmentUploadPipeline } from './S3UploadPipeline';
|
||||
import { LinkAttachment } from './LinkAttachment';
|
||||
import { UnlinkAttachment } from './UnlinkAttachment';
|
||||
import { getAttachmentPresignedUrl } from './GetAttachmentPresignedUrl';
|
||||
import type { Multer } from 'multer';
|
||||
|
||||
@Service()
|
||||
export class AttachmentsApplication {
|
||||
@@ -31,18 +32,18 @@ export class AttachmentsApplication {
|
||||
private getPresignedUrlService: getAttachmentPresignedUrl;
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns
|
||||
* Express middleware for uploading attachments to an S3 bucket.
|
||||
* @returns {Multer}
|
||||
*/
|
||||
get uploadPipeline() {
|
||||
get uploadPipeline(): Multer {
|
||||
return this.uploadPipelineService.uploadPipeline();
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads
|
||||
* Saves the metadata of uploaded document to S3 on database.
|
||||
* @param {number} tenantId
|
||||
* @param {} file
|
||||
* @returns
|
||||
* @returns {Promise<Document>}
|
||||
*/
|
||||
public upload(tenantId: number, file: any) {
|
||||
return this.uploadDocumentService.upload(tenantId, file);
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
import multer from 'multer';
|
||||
import type { Multer } from 'multer'
|
||||
import multerS3 from 'multer-s3';
|
||||
import { s3 } from '@/lib/S3/S3';
|
||||
import { Service } from 'typedi';
|
||||
import config from '@/config';
|
||||
|
||||
@Service()
|
||||
export class AttachmentUploadPipeline {
|
||||
uploadPipeline() {
|
||||
/**
|
||||
* Express middleware for uploading attachments to an S3 bucket.
|
||||
* It utilizes the multer middleware for handling multipart/form-data, specifically for file uploads.
|
||||
*/
|
||||
public uploadPipeline(): Multer {
|
||||
return multer({
|
||||
storage: multerS3({
|
||||
s3,
|
||||
bucket: process.env.AWS_BUCKET,
|
||||
bucket: config.s3.bucket,
|
||||
contentType: multerS3.AUTO_CONTENT_TYPE,
|
||||
metadata: function (req, file, cb) {
|
||||
cb(null, { fieldName: file.fieldname });
|
||||
|
||||
Reference in New Issue
Block a user