-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #481 from boostcampwm2023/BE-GreenEye-#476
[BE/#476] Green Eye 적용 코드 구현
- Loading branch information
Showing
4 changed files
with
49 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import axios from 'axios'; | ||
import { uuid } from 'uuidv4'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class GreenEyeHandler { | ||
constructor(private configService: ConfigService) {} | ||
async isHarmful(fileLocation: string): Promise<boolean> { | ||
const response = await this.sendGreenEyeRequest(fileLocation); | ||
const normalResult = response.data.images[0].result.normal.confidence; | ||
return normalResult < 0.8; | ||
} | ||
|
||
async sendGreenEyeRequest(url: string) { | ||
return await axios.post( | ||
this.configService.get('CLOVA_URL'), | ||
{ | ||
images: [ | ||
{ | ||
name: 'file', | ||
url: url, | ||
}, | ||
], | ||
requestId: uuid(), | ||
timestamp: 0, | ||
version: 'V1', | ||
}, | ||
{ | ||
headers: { | ||
'X-GREEN-EYE-SECRET': this.configService.get('CLOVA_SECRET'), | ||
}, | ||
}, | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.