mirror of
https://github.com/immich-app/immich.git
synced 2025-12-19 09:13:14 +03:00
chunked upload controller
This commit is contained in:
42
server/src/controllers/asset-upload.controller.ts
Normal file
42
server/src/controllers/asset-upload.controller.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Controller, Head, Param, Patch, Post, Req, Res } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Request, Response } from 'express';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { Permission } from 'src/enum';
|
||||
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
||||
import { AssetUploadService } from 'src/services/asset-upload.service';
|
||||
import { UUIDParamDto } from 'src/validation';
|
||||
|
||||
@ApiTags('Upload')
|
||||
@Controller('upload')
|
||||
export class AssetUploadController {
|
||||
constructor(private service: AssetUploadService) {}
|
||||
|
||||
@Post('asset')
|
||||
@Authenticated({ sharedLink: true, permission: Permission.AssetUpload })
|
||||
handleInitialChunk(@Auth() auth: AuthDto, @Req() request: Request, @Res() response: Response): Promise<void> {
|
||||
return this.service.handleInitialChunk(auth, request, response);
|
||||
}
|
||||
|
||||
@Patch('asset/:id')
|
||||
@Authenticated({ sharedLink: true, permission: Permission.AssetUpload })
|
||||
handleRemainingChunks(
|
||||
@Auth() auth: AuthDto,
|
||||
@Param() { id }: UUIDParamDto,
|
||||
@Req() request: Request,
|
||||
@Res() response: Response,
|
||||
): Promise<void> {
|
||||
return this.service.handleRemainingChunks(auth, id, request, response);
|
||||
}
|
||||
|
||||
@Head('asset/:id')
|
||||
@Authenticated({ sharedLink: true, permission: Permission.AssetUpload })
|
||||
getUploadStatus(
|
||||
@Auth() auth: AuthDto,
|
||||
@Param() { id }: UUIDParamDto,
|
||||
@Req() request: Request,
|
||||
@Res() response: Response,
|
||||
): Promise<void> {
|
||||
return this.service.getUploadStatus(auth, id, request, response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user