Skip to content

Commit

Permalink
✨ Feature(custom): optimize detele function for aws s3
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuingsmile committed Oct 23, 2023
1 parent 9ad13d4 commit b7b86b2
Show file tree
Hide file tree
Showing 3 changed files with 242 additions and 29 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@
"multer": "^1.4.5-lts.1",
"node-ssh-no-cpu-features": "^1.0.1",
"nodejs-file-downloader": "^4.12.1",
"piclist": "^1.6.3",
"piclist": "^1.6.4",
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.0",
"qiniu": "^7.10.0",
"proxy-agent": "^5.0.0",
"qiniu": "7.9.0",
"qrcode.vue": "^3.4.1",
"querystring": "^0.2.1",
"shell-path": "2.1.0",
Expand Down
6 changes: 5 additions & 1 deletion src/main/utils/deleteFunc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ async function getDogeToken (accessKey: string, secretKey: string): Promise<{} |

export async function removeFileFromS3InMain (configMap: IStringKeyMap, dogeMode: boolean = false) {
try {
const { imgUrl, config: { accessKeyID, secretAccessKey, bucketName, region, endpoint, pathStyleAccess, rejectUnauthorized, proxy } } = configMap
const { imgUrl, config: { accessKeyID, secretAccessKey, bucketName, endpoint, pathStyleAccess, rejectUnauthorized, proxy } } = configMap
let { config: { region } } = configMap
const url = new URL(!/^https?:\/\//.test(imgUrl) ? `http://${imgUrl}` : imgUrl)
let fileKey = url.pathname.replace(/^\/+/, '')
if (pathStyleAccess) {
Expand All @@ -84,6 +85,9 @@ export async function removeFileFromS3InMain (configMap: IStringKeyMap, dogeMode
? endpoint
: `http://${endpoint}`
: undefined
if (endpointUrl && endpointUrl.includes('cloudflarestorage')) {
region = region || 'auto'
}
const sslEnabled = endpointUrl ? endpointUrl.startsWith('https') : true
const agent = getAgent(proxy, sslEnabled)
const commonOptions: AgentOptions = {
Expand Down
Loading

0 comments on commit b7b86b2

Please sign in to comment.