From 390742c85b87594119e3299ef40c8e429a1ed2c6 Mon Sep 17 00:00:00 2001 From: MajedAlaitwniCap Date: Thu, 2 Nov 2023 10:49:21 +0100 Subject: [PATCH 1/2] remove unused import --- .../h5p-editor/service/temporary-file-storage.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.ts b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.ts index 7760ceb95ec..a5bc817b732 100644 --- a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.ts +++ b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.ts @@ -1,12 +1,12 @@ import { ITemporaryFile, ITemporaryFileStorage, IUser } from '@lumieducation/h5p-server'; -import { ForbiddenException, Inject, Injectable, NotAcceptableException } from '@nestjs/common'; +import { Inject, Injectable, NotAcceptableException } from '@nestjs/common'; import { S3ClientAdapter } from '@shared/infra/s3-client'; import { ReadStream } from 'fs'; import { Readable } from 'stream'; +import { H5pFileDto } from '../controller/dto/h5p-file.dto'; import { H5pEditorTempFile } from '../entity/base-entity-with-timestamp.entity'; import { H5P_CONTENT_S3_CONNECTION } from '../h5p-editor.config'; import { TemporaryFileRepo } from '../repo/temporary-file.repo'; -import { H5pFileDto } from '../controller/dto/h5p-file.dto'; @Injectable() export class TemporaryFileStorage implements ITemporaryFileStorage { From 72f713d88c05439ef582d90434f5438885626665 Mon Sep 17 00:00:00 2001 From: MajedAlaitwniCap Date: Thu, 2 Nov 2023 10:59:56 +0100 Subject: [PATCH 2/2] added H5p File Response interface --- .../modules/h5p-editor/controller/dto/h5p-file.dto.ts | 9 +++++++++ .../service/temporary-file-storage.service.spec.ts | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/server/src/modules/h5p-editor/controller/dto/h5p-file.dto.ts b/apps/server/src/modules/h5p-editor/controller/dto/h5p-file.dto.ts index 979503b9511..abb83decc85 100644 --- a/apps/server/src/modules/h5p-editor/controller/dto/h5p-file.dto.ts +++ b/apps/server/src/modules/h5p-editor/controller/dto/h5p-file.dto.ts @@ -14,3 +14,12 @@ export class H5pFileDto implements File { mimeType: string; } + +export interface GetH5pFileResponse { + data: Readable; + etag?: string; + contentType?: string; + contentLength?: number; + contentRange?: string; + name: string; +} diff --git a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts index c93c3c555b2..0dd11c1a309 100644 --- a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts +++ b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts @@ -3,9 +3,9 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { IUser } from '@lumieducation/h5p-server'; import { Test, TestingModule } from '@nestjs/testing'; import { File, S3ClientAdapter } from '@shared/infra/s3-client'; -import { GetFileResponse } from '@src/modules/files-storage/interface'; import { ReadStream } from 'fs'; import { Readable } from 'node:stream'; +import { GetH5pFileResponse } from '../controller/dto'; import { H5pEditorTempFile } from '../entity/base-entity-with-timestamp.entity'; import { H5P_CONTENT_S3_CONNECTION } from '../h5p-editor.config'; import { TemporaryFileRepo } from '../repo/temporary-file.repo'; @@ -187,7 +187,7 @@ describe('TemporaryFileStorage', () => { it('should return readable file stream', async () => { const { user1, file1 } = setup(); const actualContent = fileContent(user1.id, file1.filename); - const response: Required = { + const response: Required = { data: Readable.from(actualContent), etag: '', contentType: '',