feat: add config variable to adjust chunk size

This commit is contained in:
Elias Schneider
2024-04-04 20:54:21 +02:00
parent 82871ce5dc
commit 0bfbaea49a
4 changed files with 18 additions and 3 deletions

View File

@@ -47,7 +47,7 @@ export class FileService {
}
// If the sent chunk index and the expected chunk index doesn't match throw an error
const chunkSize = 10 * 1024 * 1024; // 10MB
const chunkSize = this.config.get("share.chunkSize");
const expectedChunkIndex = Math.ceil(diskFileSize / chunkSize);
if (expectedChunkIndex != chunk.index)

View File

@@ -7,13 +7,21 @@ import * as cookieParser from "cookie-parser";
import * as fs from "fs";
import { AppModule } from "./app.module";
import { DATA_DIRECTORY } from "./constants";
import { ConfigService } from "./config/config.service";
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.useGlobalPipes(new ValidationPipe({ whitelist: true }));
app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));
app.use(bodyParser.raw({ type: "application/octet-stream", limit: "20mb" }));
const config = app.get<ConfigService>(ConfigService);
app.use(
bodyParser.raw({
type: "application/octet-stream",
limit: `${config.get("share.chunkSize")}B`,
}),
);
app.use(cookieParser());
app.set("trust proxy", true);