feat: add setup wizard
This commit is contained in:
@@ -18,7 +18,6 @@ import { ShareDTO } from "src/share/dto/share.dto";
|
||||
import { ShareOwnerGuard } from "src/share/guard/shareOwner.guard";
|
||||
import { ShareSecurityGuard } from "src/share/guard/shareSecurity.guard";
|
||||
import { FileService } from "./file.service";
|
||||
import { FileValidationPipe } from "./pipe/fileValidation.pipe";
|
||||
|
||||
@Controller("shares/:shareId/files")
|
||||
export class FileController {
|
||||
@@ -32,7 +31,7 @@ export class FileController {
|
||||
})
|
||||
)
|
||||
async create(
|
||||
@UploadedFile(FileValidationPipe)
|
||||
@UploadedFile()
|
||||
file: Express.Multer.File,
|
||||
@Param("shareId") shareId: string
|
||||
) {
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import { ArgumentMetadata, Injectable, PipeTransform } from "@nestjs/common";
|
||||
import {
|
||||
ArgumentMetadata,
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
PipeTransform,
|
||||
} from "@nestjs/common";
|
||||
import { ConfigService } from "src/config/config.service";
|
||||
|
||||
@Injectable()
|
||||
export class FileValidationPipe implements PipeTransform {
|
||||
constructor(private config: ConfigService) {}
|
||||
async transform(value: any, metadata: ArgumentMetadata) {
|
||||
// "value" is an object containing the file's attributes and metadata
|
||||
console.log(this.config.get("maxFileSize"));
|
||||
const oneKb = 1000;
|
||||
return value.size < oneKb;
|
||||
if (value.size > this.config.get("maxFileSize"))
|
||||
throw new BadRequestException("File is ");
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user