add default file service (#1627)

This commit is contained in:
Philip Korsholm
2022-06-10 22:24:11 +08:00
committed by GitHub
parent 1fe518b4af
commit d011f38305

View File

@@ -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<any> {
upload(fileData: Express.Multer.File): Promise<FileServiceUploadResult> {
throw new MedusaError(
MedusaError.Types.UNEXPECTED_STATE,
"Please add a file service plugin in order to manipulate files in Medusa"
)
}
delete(fileData: Record<string, any>): 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<FileServiceGetUploadStreamResult> {
throw new MedusaError(
MedusaError.Types.UNEXPECTED_STATE,
"Please add a file service plugin in order to manipulate files in Medusa"
)
}
getDownloadStream(
fileData: GetUploadedFileType
): Promise<NodeJS.ReadableStream> {
throw new MedusaError(
MedusaError.Types.UNEXPECTED_STATE,
"Please add a file service plugin in order to manipulate files in Medusa"
)
}
getPresignedDownloadUrl(fileData: GetUploadedFileType): Promise<string> {
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