+
+ @AfterDestroy
+ static removeFilesAndSendDelete (instance: AvatarModel) {
+ return instance.removeAvatar()
+ }
+
+ toFormattedJSON (): Avatar {
+ return {
+ path: this.getWebserverPath(),
+ createdAt: this.createdAt,
+ updatedAt: this.updatedAt
+ }
+ }
+
+ getWebserverPath () {
+ return join(STATIC_PATHS.AVATARS, this.filename)
+ }
+
+ removeAvatar () {
+ const avatarPath = join(CONFIG.STORAGE.AVATARS_DIR, this.filename)
+ return unlinkPromise(avatarPath)
+ }