35 lines
748 B
TypeScript
35 lines
748 B
TypeScript
import AbstractService from './abstractService'
|
|
import ProjectModel from '@/models/project'
|
|
|
|
import type { IProject } from '@/modelTypes/IProject'
|
|
import type { IFile } from '@/modelTypes/IFile'
|
|
|
|
const paths = {
|
|
create: '/projects/{projectId}/backgrounds/upload',
|
|
} as const
|
|
|
|
export default class BackgroundUploadService extends AbstractService<IProject, typeof paths> {
|
|
constructor() {
|
|
super(paths)
|
|
}
|
|
|
|
useCreateInterceptor() {
|
|
return false
|
|
}
|
|
|
|
modelCreateFactory(data: Partial<IProject>) {
|
|
return new ProjectModel(data)
|
|
}
|
|
|
|
/**
|
|
* Uploads a file to the server
|
|
*/
|
|
create(projectId: IProject['id'], file: IFile) {
|
|
return this.uploadFile(
|
|
this.getReplacedRoute(this.paths.create, {projectId}),
|
|
file,
|
|
'background',
|
|
)
|
|
}
|
|
}
|