From bfb4305d01bb689758e4373caf368d4d84282c41 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Fri, 5 Jun 2026 11:17:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:buildAuthHeader=E7=AD=BE=E5=90=8D=E9=93=BE?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0content-type,=E4=B8=8Ecurl=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/minio.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/minio.js b/utils/minio.js index 01c3f29..64542c8 100644 --- a/utils/minio.js +++ b/utils/minio.js @@ -127,7 +127,7 @@ function getServerDate() { /** * 为 PUT 请求构建 Authorization 签名头 */ -function buildAuthHeader(objectKey, date) { +function buildAuthHeader(objectKey, date, contentType) { const dateStr = date.getFullYear() + pad(date.getMonth() + 1) + pad(date.getDate()) const amzDate = dateStr + 'T' + pad(date.getHours()) + pad(date.getMinutes()) + pad(date.getSeconds()) + 'Z' @@ -135,6 +135,7 @@ function buildAuthHeader(objectKey, date) { const canonicalUri = '/' + CFG.bucket + '/' + objectKey const signedHeadersMap = { + 'content-type': contentType || 'image/jpeg', host: host, 'x-amz-content-sha256': 'UNSIGNED-PAYLOAD', 'x-amz-date': amzDate @@ -419,7 +420,7 @@ export function uploadImage(filePath, typeDir = 'Isbn') { const contentType = getContentType(ext) // 构建 AWS V4 签名 - const { authHeader, amzDate, host } = buildAuthHeader(objectKey, now) + const { authHeader, amzDate, host } = buildAuthHeader(objectKey, now, contentType) // PUT URL const url = CFG.protocol + '://' + host + '/' + CFG.bucket + '/' + objectKey