From d011f383059c70ee3bac53bbef5dc7310310c3c3 Mon Sep 17 00:00:00 2001 From: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com> Date: Fri, 10 Jun 2022 22:24:11 +0800 Subject: [PATCH] add default file service (#1627) --- packages/medusa/src/services/file.ts | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 packages/medusa/src/services/file.ts diff --git a/packages/medusa/src/services/file.ts b/packages/medusa/src/services/file.ts new file mode 100644 index 0000000000..cc4121b218 --- /dev/null +++ b/packages/medusa/src/services/file.ts @@ -0,0 +1,50 @@ +import { MedusaError } from "medusa-core-utils" +import { EntityManager } from "typeorm" +import { + AbstractFileService, + FileServiceGetUploadStreamResult, + FileServiceUploadResult, + GetUploadedFileType, + UploadStreamDescriptorType, +} from "../interfaces" + +class DefaultFileService extends AbstractFileService { + upload(fileData: Express.Multer.File): Promise { + throw new MedusaError( + MedusaError.Types.UNEXPECTED_STATE, + "Please add a file service plugin in order to manipulate files in Medusa" + ) + } + delete(fileData: Record): void { + throw new MedusaError( + MedusaError.Types.UNEXPECTED_STATE, + "Please add a file service plugin in order to manipulate files in Medusa" + ) + } + getUploadStreamDescriptor( + fileData: UploadStreamDescriptorType + ): Promise { + throw new MedusaError( + MedusaError.Types.UNEXPECTED_STATE, + "Please add a file service plugin in order to manipulate files in Medusa" + ) + } + getDownloadStream( + fileData: GetUploadedFileType + ): Promise { + throw new MedusaError( + MedusaError.Types.UNEXPECTED_STATE, + "Please add a file service plugin in order to manipulate files in Medusa" + ) + } + getPresignedDownloadUrl(fileData: GetUploadedFileType): Promise { + throw new MedusaError( + MedusaError.Types.UNEXPECTED_STATE, + "Please add a file service plugin in order to manipulate files in Medusa" + ) + } + protected manager_: EntityManager + protected transactionManager_: EntityManager | undefined +} + +export default DefaultFileService