Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Updated bucket policies for AWS_S3
Browse files Browse the repository at this point in the history
  • Loading branch information
nmashchenko committed Jul 3, 2023
1 parent 05412ec commit 81019ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions server/src/maintenance/maintenance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export class MaintenanceService {
const update = this.updateGeneratedUser(user.email);

const randomIndex = Math.floor(Math.random() * this.images.length);

await this.usersService.updateAvatar({
email: user.email,
image: this.images[randomIndex],
Expand Down
7 changes: 5 additions & 2 deletions server/src/teams/teams.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,17 @@ export class TeamsService {
/* Checking if the user has an image. If it does, it is removing the image. */
if (candidateTeam.image) {
const path = this.getPath(candidateTeam.image, 'image');
await this.filesService.removeFromS3(path, 'teameights');
await this.filesService.removeFromS3(
path,
process.env.AWS_S3_BUCKET,
);
}

/* Creating a file in the static folder. */
const filePath = await this.filesService.createFile(
FileType.TEAMS,
dto.image,
'teameights',
process.env.AWS_S3_BUCKET,
);

/* Updating the user with the given email with the new data and returning the updated user. */
Expand Down
7 changes: 5 additions & 2 deletions server/src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,17 @@ export class UsersService {
/* Checking if the user has an image. If it does, it is removing the image. */
if (candidate.image) {
const path = this.getPath(candidate.image, 'image');
await this.filesService.removeFromS3(path, 'teameights');
await this.filesService.removeFromS3(
path,
process.env.AWS_S3_BUCKET,
);
}

/* Creating a file in the static folder. */
const filePath = await this.filesService.createFile(
FileType.USERS,
dto.image,
'teameights',
process.env.AWS_S3_BUCKET,
);

/* Updating the user with the given email with the new data and returning the updated user. */
Expand Down

0 comments on commit 81019ef

Please sign in to comment.