Usecase: We have files in an S3 bucket with the respective information in our database. I would like to provide only an url for the frontend. Is this even possible?
At the moment it loads the whole object:
"descriptionFile": {
"id": 99,
"createdAt": "2020-07-23T11:58:59.510Z",
"updatedAt": "2020-07-23T11:58:59.510Z",
"s3Identifier": "asdfasdf-2we3123r99"
},
Goal: To only have an url in the response:
"descriptionFileUrl": "https://myapi.com/api/media/asdfasdf-2we3123r99"
These are my entities:
// category.entity.ts
@OneToOne(type => S3File)
@JoinColumn({ name: 'description_file_id' })
public descriptionFile: S3File;
// s3-file.entity.ts
@Column({ name: 's3_identifier', nullable: false })
public s3Identifier: string;
public get fullUrl() {
return 'https://' + this.s3Identifier;
}
Service function that load the data:
this.categoryRepository.find({
relations: [..., 'descriptionFile'],
});