fix: Create basic representations with streams.

This commit is contained in:
Ruben Verborgh
2021-01-20 16:16:33 +01:00
committed by Joachim Van Herwegen
parent 5416d66a31
commit b487dc738c
4 changed files with 36 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
import { promises as fs } from 'fs';
import { createReadStream } from 'fs';
import { BasicRepresentation } from '../../ldp/representation/BasicRepresentation';
import type { Representation } from '../../ldp/representation/Representation';
import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError';
@@ -52,7 +52,7 @@ export class ConstantConverter extends RepresentationConverter {
representation.data.destroy();
// Create a new representation from the constant file
const data = await fs.readFile(this.filePath, 'utf8');
const data = createReadStream(this.filePath, 'utf8');
return new BasicRepresentation(data, representation.metadata, this.contentType);
}
}