mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-08-05 13:18:35 +08:00
✨ Feature: s3-compatible storage is supported now
This commit is contained in:
@@ -4,11 +4,11 @@ export default class AwsS3Api {
|
||||
static async delete (configMap: IStringKeyMap): Promise<boolean> {
|
||||
const { imgUrl, config: { accessKeyID, secretAccessKey, bucketName, region, endpoint, pathStyleAccess, bucketEndpoint, rejectUnauthorized } } = configMap
|
||||
try {
|
||||
const url = new URL((!imgUrl.startsWith('http') && !imgUrl.startsWith('https')) ? `http://${imgUrl}` : imgUrl)
|
||||
const url = new URL(!/^https?:\/\//.test(imgUrl) ? `http://${imgUrl}` : imgUrl)
|
||||
const fileKey = url.pathname
|
||||
let endpointUrl
|
||||
if (endpoint) {
|
||||
if (!endpoint.startsWith('http') && !endpoint.startsWith('https')) {
|
||||
if (!/^https?:\/\//.test(endpoint)) {
|
||||
endpointUrl = `http://${endpoint}`
|
||||
} else {
|
||||
endpointUrl = endpoint
|
||||
@@ -29,7 +29,8 @@ export default class AwsS3Api {
|
||||
s3BucketEndpoint: bucketEndpoint,
|
||||
httpOptions: {
|
||||
agent: new http.Agent({
|
||||
rejectUnauthorized
|
||||
rejectUnauthorized,
|
||||
timeout: 30000
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@ export default class ImgurApi {
|
||||
try {
|
||||
const res = await axios.delete(fullUrl, {
|
||||
headers,
|
||||
timeout: 10000
|
||||
timeout: 30000
|
||||
})
|
||||
return res.status === 200
|
||||
} catch (error) {
|
||||
|
||||
@@ -15,7 +15,7 @@ export default class SmmsApi {
|
||||
hash,
|
||||
format: 'json'
|
||||
},
|
||||
timeout: 10000
|
||||
timeout: 30000
|
||||
})
|
||||
return res.status === 200
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user