mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-06 05:09:09 +08:00
🐛 fix: Configure S3 client to bypass proxy for reliable uploads
Co-authored-by: GeorgeDong32 <98630204+GeorgeDong32@users.noreply.github.com>
This commit is contained in:
parent
33983c26f4
commit
7a49042d7f
@ -6,9 +6,11 @@ import {
|
|||||||
PutObjectCommand,
|
PutObjectCommand,
|
||||||
S3Client
|
S3Client
|
||||||
} from '@aws-sdk/client-s3'
|
} from '@aws-sdk/client-s3'
|
||||||
|
import { FetchHttpHandler } from '@smithy/fetch-http-handler'
|
||||||
import { loggerService } from '@logger'
|
import { loggerService } from '@logger'
|
||||||
import type { S3Config } from '@types'
|
import type { S3Config } from '@types'
|
||||||
import * as net from 'net'
|
import * as net from 'net'
|
||||||
|
import { Agent as UndiciAgent } from 'undici'
|
||||||
import { Readable } from 'stream'
|
import { Readable } from 'stream'
|
||||||
|
|
||||||
const logger = loggerService.withContext('S3Storage')
|
const logger = loggerService.withContext('S3Storage')
|
||||||
@ -57,6 +59,20 @@ export default class S3Storage {
|
|||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
// Create a direct dispatcher for S3 to bypass proxy
|
||||||
|
// This prevents proxy interference with large file uploads that can cause incomplete transfers
|
||||||
|
const directDispatcher = new UndiciAgent({
|
||||||
|
connect: {
|
||||||
|
timeout: 60000 // 60 second connection timeout
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Use FetchHttpHandler with direct dispatcher to bypass global proxy settings
|
||||||
|
const requestHandler = new FetchHttpHandler({
|
||||||
|
requestTimeout: 300000, // 5 minute request timeout for large files
|
||||||
|
dispatcher: directDispatcher
|
||||||
|
})
|
||||||
|
|
||||||
this.client = new S3Client({
|
this.client = new S3Client({
|
||||||
region,
|
region,
|
||||||
endpoint: endpoint || undefined,
|
endpoint: endpoint || undefined,
|
||||||
@ -64,7 +80,8 @@ export default class S3Storage {
|
|||||||
accessKeyId: accessKeyId,
|
accessKeyId: accessKeyId,
|
||||||
secretAccessKey: secretAccessKey
|
secretAccessKey: secretAccessKey
|
||||||
},
|
},
|
||||||
forcePathStyle: usePathStyle
|
forcePathStyle: usePathStyle,
|
||||||
|
requestHandler
|
||||||
})
|
})
|
||||||
|
|
||||||
this.bucket = bucket
|
this.bucket = bucket
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user