Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

413 - File Too Large Error #541

Open
CodyxKarthi opened this issue Jan 16, 2025 · 0 comments
Open

413 - File Too Large Error #541

CodyxKarthi opened this issue Jan 16, 2025 · 0 comments

Comments

@CodyxKarthi
Copy link

Hi,

I am getting 413, File too Large error. While uploading a file to S3.

I have adjusted to the middleware config to accept 50mb.

body: {
json: {
maxFileSize: '50mb',//'100kb', //bytes('100kb'), // 100kb
},
raw: {
maxFileSize: '50mb', //'100kb' //bytes('100kb'), // 100kb
},
text: {
maxFileSize: '50mb', //'100kb' //bytes('100kb'), // 100kb
},
urlencoded: {
maxFileSize: '50mb', // '100kb' //bytes('100kb'), // 100kb
},
},

Still when i try to upload 10mb file, i am getting the above error.

In the Body Parser Middle where, i have validate the maxFile, size and content-length.. every thing is as excepted, still i am getting this error;

@Injectable()
export class AppTextBodyParserMiddleware implements NestMiddleware {
private maxFile: number;

constructor(private readonly configService: ConfigService) {
    this.maxFile = this.configService.get<number>(
        'middleware.body.text.maxFileSize'
    );
}

use(req: Request, res: Response, next: NextFunction): void {
    console.log(`Max file size: ${this.maxFile}`);
    console.log(`Content-Length: ${req.headers['content-length']}`);
    
    bodyParser.text({
        limit: this.maxFile,
    })(req, res, next);
}

}

even i have removed the condition and return next() always , the error didn't disappear

@Injectable()
export class AppTextBodyParserMiddleware implements NestMiddleware {
private maxFile: number;

constructor(private readonly configService: ConfigService) {
    this.maxFile = this.configService.get<number>(
        'middleware.body.text.maxFileSize'
    );
}

use(req: Request, res: Response, next: NextFunction): void {
    console.log(`Max file size: ${this.maxFile}`);
    console.log(`Content-Length: ${req.headers['content-length']}`);
    
    return next()
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant