mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 13:49:40 +00:00
feat: finish generating signed url for document upload flow
This commit is contained in:
@ -1,31 +1,35 @@
|
|||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { Document } from '~/document/entities';
|
import { Document } from '~/document/entities';
|
||||||
import { DocumentType } from '~/document/enums';
|
import { DocumentType, UploadStatus } from '~/document/enums';
|
||||||
const DEFAULT_TASK_LOGOS = [
|
const DEFAULT_TASK_LOGOS = [
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'bed-furniture',
|
name: 'bed-furniture',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'dog',
|
name: 'dog',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'dish-washing',
|
name: 'dish-washing',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'walking-the-dog',
|
name: 'walking-the-dog',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
documentType: DocumentType.DEFAULT_TASKS_LOGO,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
export class SeedsDefaultTasksLogo1733990253208 implements MigrationInterface {
|
export class SeedsDefaultTasksLogo1733990253208 implements MigrationInterface {
|
||||||
|
@ -1,61 +1,70 @@
|
|||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { Document } from '../../document/entities';
|
import { Document } from '../../document/entities';
|
||||||
import { DocumentType } from '../../document/enums';
|
import { DocumentType, UploadStatus } from '../../document/enums';
|
||||||
const DEFAULT_AVATARS = [
|
const DEFAULT_AVATARS = [
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'vacation',
|
name: 'vacation',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_AVATAR,
|
documentType: DocumentType.DEFAULT_AVATAR,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'colors',
|
name: 'colors',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_AVATAR,
|
documentType: DocumentType.DEFAULT_AVATAR,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'astronaut',
|
name: 'astronaut',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_AVATAR,
|
documentType: DocumentType.DEFAULT_AVATAR,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'pet',
|
name: 'pet',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_AVATAR,
|
documentType: DocumentType.DEFAULT_AVATAR,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'disney',
|
name: 'disney',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_AVATAR,
|
documentType: DocumentType.DEFAULT_AVATAR,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'clothes',
|
name: 'clothes',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_AVATAR,
|
documentType: DocumentType.DEFAULT_AVATAR,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'playstation',
|
name: 'playstation',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_AVATAR,
|
documentType: DocumentType.DEFAULT_AVATAR,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'football',
|
name: 'football',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_AVATAR,
|
documentType: DocumentType.DEFAULT_AVATAR,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: 'cars',
|
name: 'cars',
|
||||||
extension: '.jpg',
|
extension: '.jpg',
|
||||||
documentType: DocumentType.DEFAULT_AVATAR,
|
documentType: DocumentType.DEFAULT_AVATAR,
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
export class SeedDefaultAvatar1753869637732 implements MigrationInterface {
|
export class SeedDefaultAvatar1753869637732 implements MigrationInterface {
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
|
export class AddUploadStatusToDocumentEntity1754226754947 implements MigrationInterface {
|
||||||
|
name = 'AddUploadStatusToDocumentEntity1754226754947';
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "documents" ADD "upload_status" character varying(255) NOT NULL DEFAULT 'NOT_UPLOADED'`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "documents" DROP COLUMN "upload_status"`);
|
||||||
|
}
|
||||||
|
}
|
@ -5,3 +5,4 @@ export * from './1753869637732-seed-default-avatar';
|
|||||||
export * from './1753874205042-add-neoleap-related-entities';
|
export * from './1753874205042-add-neoleap-related-entities';
|
||||||
export * from './1753948642040-add-account-number-and-iban-to-account-entity';
|
export * from './1753948642040-add-account-number-and-iban-to-account-entity';
|
||||||
export * from './1754210729273-add-vpan-to-card';
|
export * from './1754210729273-add-vpan-to-card';
|
||||||
|
export * from './1754226754947-add-upload-status-to-document-entity';
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import { Body, Controller, Post, UseGuards } from '@nestjs/common';
|
import { Body, Controller, HttpCode, HttpStatus, Param, Post, UseGuards } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiNoContentResponse, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { IJwtPayload } from '~/auth/interfaces';
|
||||||
|
import { AuthenticatedUser } from '~/common/decorators';
|
||||||
import { AccessTokenGuard } from '~/common/guards';
|
import { AccessTokenGuard } from '~/common/guards';
|
||||||
import { ApiLangRequestHeader } from '~/core/decorators';
|
import { ApiDataResponse, ApiLangRequestHeader } from '~/core/decorators';
|
||||||
import { ResponseFactory } from '~/core/utils';
|
import { ResponseFactory } from '~/core/utils';
|
||||||
import { GenerateUploadSignedUrlRequestDto } from '../dtos/request';
|
import { CreateDocumentRequestDto } from '../dtos/request';
|
||||||
|
import { GenerateUploadSignedUrlResponseDto } from '../dtos/response';
|
||||||
import { DocumentService } from '../services';
|
import { DocumentService } from '../services';
|
||||||
@Controller('document')
|
@Controller('document')
|
||||||
@ApiTags('Document')
|
@ApiTags('Document')
|
||||||
@ -14,8 +17,16 @@ export class DocumentController {
|
|||||||
constructor(private readonly documentService: DocumentService) {}
|
constructor(private readonly documentService: DocumentService) {}
|
||||||
|
|
||||||
@Post('signed-url')
|
@Post('signed-url')
|
||||||
async generateSignedUrl(@Body() body: GenerateUploadSignedUrlRequestDto) {
|
@ApiDataResponse(GenerateUploadSignedUrlResponseDto)
|
||||||
const signedUrl = await this.documentService.generateUploadSignedUrl(body);
|
async generateSignedUrl(@AuthenticatedUser() { sub }: IJwtPayload, @Body() body: CreateDocumentRequestDto) {
|
||||||
return ResponseFactory.data(signedUrl);
|
const result = await this.documentService.generateUploadSignedUrl(sub, body);
|
||||||
|
return ResponseFactory.data(new GenerateUploadSignedUrlResponseDto(result.document, result.uploadUrl));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post(':documentId/confirm-update')
|
||||||
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@ApiNoContentResponse({ description: 'Document update confirmed successfully' })
|
||||||
|
async confirmDocumentUpdate(@Param('documentId') documentId: string) {
|
||||||
|
return this.documentService.confirmDocumentUpdate(documentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,12 @@ import { IsEnum, IsString } from 'class-validator';
|
|||||||
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
|
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
|
||||||
import { DocumentType } from '~/document/enums';
|
import { DocumentType } from '~/document/enums';
|
||||||
|
|
||||||
export class GenerateUploadSignedUrlRequestDto {
|
export class CreateDocumentRequestDto {
|
||||||
@ApiProperty({ enum: DocumentType })
|
@ApiProperty({ enum: DocumentType })
|
||||||
@IsEnum(DocumentType, { message: i18n('validation.IsEnum', { path: 'general', property: 'document.documentType' }) })
|
@IsEnum(DocumentType, { message: i18n('validation.IsEnum', { path: 'general', property: 'document.documentType' }) })
|
||||||
documentType!: DocumentType;
|
documentType!: DocumentType;
|
||||||
|
|
||||||
@ApiProperty({ type: String })
|
@ApiProperty({ type: String, example: '.jpg' })
|
||||||
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'document.document.extension' }) })
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'document.document.extension' }) })
|
||||||
extension!: string;
|
extension!: string;
|
||||||
|
|
@ -1,2 +1 @@
|
|||||||
export * from './generate-upload-signed-url.request.dto';
|
export * from './create-document.request.dto';
|
||||||
export * from './upload-document.request.dto';
|
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
import { IsEnum } from 'class-validator';
|
|
||||||
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
|
|
||||||
import { DocumentType } from '~/document/enums';
|
|
||||||
|
|
||||||
export class UploadDocumentRequestDto {
|
|
||||||
@IsEnum(DocumentType, { message: i18n('validation.IsEnum', { path: 'general', property: 'document.documentType' }) })
|
|
||||||
documentType!: DocumentType;
|
|
||||||
}
|
|
@ -0,0 +1,16 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Document } from '~/document/entities';
|
||||||
|
import { DocumentMetaResponseDto } from './document-meta.response.dto';
|
||||||
|
|
||||||
|
export class GenerateUploadSignedUrlResponseDto {
|
||||||
|
@ApiProperty({ type: DocumentMetaResponseDto })
|
||||||
|
document!: DocumentMetaResponseDto;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
uploadUrl!: string;
|
||||||
|
|
||||||
|
constructor(document: Document, uploadUrl: string) {
|
||||||
|
this.document = new DocumentMetaResponseDto(document);
|
||||||
|
this.uploadUrl = uploadUrl;
|
||||||
|
}
|
||||||
|
}
|
@ -1,2 +1,3 @@
|
|||||||
export * from './document-meta.response.dto';
|
export * from './document-meta.response.dto';
|
||||||
|
export * from './generate-upload-signed-url.response.dto';
|
||||||
export * from './upload.response.dto';
|
export * from './upload.response.dto';
|
||||||
|
@ -15,13 +15,16 @@ import { SavingGoal } from '~/saving-goals/entities';
|
|||||||
import { Task } from '~/task/entities';
|
import { Task } from '~/task/entities';
|
||||||
import { TaskSubmission } from '~/task/entities/task-submissions.entity';
|
import { TaskSubmission } from '~/task/entities/task-submissions.entity';
|
||||||
import { User } from '~/user/entities';
|
import { User } from '~/user/entities';
|
||||||
import { DocumentType } from '../enums';
|
import { DocumentType, UploadStatus } from '../enums';
|
||||||
|
|
||||||
@Entity('documents')
|
@Entity('documents')
|
||||||
export class Document {
|
export class Document {
|
||||||
@PrimaryGeneratedColumn('uuid')
|
@PrimaryGeneratedColumn('uuid')
|
||||||
id!: string;
|
id!: string;
|
||||||
|
|
||||||
|
@Column({ type: 'varchar', length: 255, default: UploadStatus.NOT_UPLOADED, name: 'upload_status' })
|
||||||
|
uploadStatus!: UploadStatus;
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 255 })
|
@Column({ type: 'varchar', length: 255 })
|
||||||
name!: string;
|
name!: string;
|
||||||
|
|
||||||
|
@ -1 +1,2 @@
|
|||||||
export * from './document-type.enum';
|
export * from './document-type.enum';
|
||||||
|
export * from './upload-status.enum';
|
||||||
|
4
src/document/enums/upload-status.enum.ts
Normal file
4
src/document/enums/upload-status.enum.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export enum UploadStatus {
|
||||||
|
NOT_UPLOADED = 'NOT_UPLOADED',
|
||||||
|
UPLOADED = 'UPLOADED',
|
||||||
|
}
|
@ -26,4 +26,8 @@ export class DocumentRepository {
|
|||||||
findDocumentById(id: string) {
|
findDocumentById(id: string) {
|
||||||
return this.documentRepository.findOne({ where: { id } });
|
return this.documentRepository.findOne({ where: { id } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateDocument(id: string, updateData: Partial<Document>) {
|
||||||
|
return this.documentRepository.update(id, updateData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
import { FindOptionsWhere } from 'typeorm';
|
import { FindOptionsWhere } from 'typeorm';
|
||||||
import { GenerateUploadSignedUrlRequestDto, UploadDocumentRequestDto } from '../dtos/request';
|
import { CreateDocumentRequestDto } from '../dtos/request';
|
||||||
import { Document } from '../entities';
|
import { Document } from '../entities';
|
||||||
|
import { UploadStatus } from '../enums';
|
||||||
import { DocumentRepository } from '../repositories';
|
import { DocumentRepository } from '../repositories';
|
||||||
import { OciService } from './oci.service';
|
import { OciService } from './oci.service';
|
||||||
|
|
||||||
@ -9,11 +10,6 @@ import { OciService } from './oci.service';
|
|||||||
export class DocumentService {
|
export class DocumentService {
|
||||||
private readonly logger = new Logger(DocumentService.name);
|
private readonly logger = new Logger(DocumentService.name);
|
||||||
constructor(private readonly ociService: OciService, private readonly documentRepository: DocumentRepository) {}
|
constructor(private readonly ociService: OciService, private readonly documentRepository: DocumentRepository) {}
|
||||||
async createDocument(file: Express.Multer.File, uploadedDocumentRequest: UploadDocumentRequestDto, userId: string) {
|
|
||||||
this.logger.log(`creating document for with type ${uploadedDocumentRequest.documentType}`);
|
|
||||||
const uploadedFile = await this.ociService.uploadFile(file, uploadedDocumentRequest);
|
|
||||||
return this.documentRepository.createDocument(userId, uploadedFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
findDocuments(where: FindOptionsWhere<Document>) {
|
findDocuments(where: FindOptionsWhere<Document>) {
|
||||||
this.logger.log(`finding documents with where clause ${JSON.stringify(where)}`);
|
this.logger.log(`finding documents with where clause ${JSON.stringify(where)}`);
|
||||||
@ -25,10 +21,27 @@ export class DocumentService {
|
|||||||
return this.documentRepository.findDocumentById(id);
|
return this.documentRepository.findDocumentById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
generateUploadSignedUrl(body: GenerateUploadSignedUrlRequestDto) {
|
async confirmDocumentUpdate(documentId: string) {
|
||||||
|
const document = await this.documentRepository.findDocumentById(documentId);
|
||||||
|
if (!document) {
|
||||||
|
this.logger.error(`Document with id ${documentId} not found`);
|
||||||
|
throw new Error(`Document with id ${documentId} not found.`);
|
||||||
|
}
|
||||||
|
this.logger.log(`Confirming document update for document id ${documentId}`);
|
||||||
|
|
||||||
|
return this.documentRepository.updateDocument(documentId, {
|
||||||
|
uploadStatus: UploadStatus.UPLOADED,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async generateUploadSignedUrl(userId: string, body: CreateDocumentRequestDto) {
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
`generating signed URL for document type ${body.documentType} with original file name ${body.originalFileName}`,
|
`generating signed URL for document type ${body.documentType} with original file name ${body.originalFileName}`,
|
||||||
);
|
);
|
||||||
return this.ociService.generateUploadPreSignedUrl(body);
|
const uploadResult = await this.ociService.generateUploadPreSignedUrl(body);
|
||||||
|
|
||||||
|
const document = await this.documentRepository.createDocument(userId, uploadResult);
|
||||||
|
|
||||||
|
return { document, uploadUrl: uploadResult.url };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,9 @@ import moment from 'moment';
|
|||||||
import { Region, SimpleAuthenticationDetailsProvider } from 'oci-common';
|
import { Region, SimpleAuthenticationDetailsProvider } from 'oci-common';
|
||||||
import { ObjectStorageClient } from 'oci-objectstorage';
|
import { ObjectStorageClient } from 'oci-objectstorage';
|
||||||
import { CreatePreauthenticatedRequestDetails } from 'oci-objectstorage/lib/model';
|
import { CreatePreauthenticatedRequestDetails } from 'oci-objectstorage/lib/model';
|
||||||
import path from 'path';
|
|
||||||
import { CacheService } from '~/common/modules/cache/services';
|
import { CacheService } from '~/common/modules/cache/services';
|
||||||
import { BUCKETS } from '../constants';
|
import { BUCKETS } from '../constants';
|
||||||
import { GenerateUploadSignedUrlRequestDto, UploadDocumentRequestDto } from '../dtos/request';
|
import { CreateDocumentRequestDto } from '../dtos/request';
|
||||||
import { UploadResponseDto } from '../dtos/response';
|
import { UploadResponseDto } from '../dtos/response';
|
||||||
import { Document } from '../entities';
|
import { Document } from '../entities';
|
||||||
import { generateNewFileName } from '../utils';
|
import { generateNewFileName } from '../utils';
|
||||||
@ -37,35 +36,6 @@ export class OciService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadFile(file: Express.Multer.File, { documentType }: UploadDocumentRequestDto): Promise<UploadResponseDto> {
|
|
||||||
this.logger.log(`Uploading file with type ${documentType}`);
|
|
||||||
const bucketName = BUCKETS[documentType];
|
|
||||||
const objectName = generateNewFileName(file.originalname);
|
|
||||||
|
|
||||||
if (!bucketName) {
|
|
||||||
this.logger.error('Could not find bucket name for document type', documentType);
|
|
||||||
throw new BadRequestException('DOCUMENT.TYPE_NOT_SUPPORTED');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.logger.debug(`Uploading file to bucket ${bucketName} with object name ${objectName}`);
|
|
||||||
await this.ociClient.putObject({
|
|
||||||
namespaceName: this.namespace,
|
|
||||||
bucketName,
|
|
||||||
putObjectBody: file.buffer,
|
|
||||||
contentLength: file.buffer.length,
|
|
||||||
objectName,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.logger.log(`File uploaded successfully to bucket ${bucketName} with object name ${objectName}`);
|
|
||||||
|
|
||||||
return plainToInstance(UploadResponseDto, {
|
|
||||||
name: objectName,
|
|
||||||
extension: path.extname(file.originalname),
|
|
||||||
url: `https://objectstorage.${this.region}.oraclecloud.com/n/${this.namespace}/b/${bucketName}/o/${objectName}`,
|
|
||||||
documentType,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async generatePreSignedUrl(document?: Document): Promise<string | any> {
|
async generatePreSignedUrl(document?: Document): Promise<string | any> {
|
||||||
this.logger.log(`Generating pre-signed url for document ${document?.id}`);
|
this.logger.log(`Generating pre-signed url for document ${document?.id}`);
|
||||||
if (!document) {
|
if (!document) {
|
||||||
@ -111,7 +81,7 @@ export class OciService {
|
|||||||
documentType,
|
documentType,
|
||||||
originalFileName,
|
originalFileName,
|
||||||
extension,
|
extension,
|
||||||
}: GenerateUploadSignedUrlRequestDto): Promise<UploadResponseDto> {
|
}: CreateDocumentRequestDto): Promise<UploadResponseDto> {
|
||||||
const bucketName = BUCKETS[documentType];
|
const bucketName = BUCKETS[documentType];
|
||||||
|
|
||||||
if (!bucketName) {
|
if (!bucketName) {
|
||||||
|
Reference in New Issue
Block a user