Spaces:
Running
Running
Surf commited on
Commit ·
408c2d2
1
Parent(s): ac6d156
对齐 R2 签名方式并修复项目存储连接
Browse files46 unmodified lines474849505152534 unmodified lines5859606162636446 unmodified linesendpoint.search = ''const payload = body == null ? Buffer.alloc(0) : Buffer.isBuffer(body) ? body : Buffer.from(body)const payloadHash = sha256(payload)const date = new Date()const amzDate = date.toISOString().replace(/[:-]|\.\d{3}/g, '')const shortDate = amzDate.slice(0, 8)4 unmodified lines'x-amz-date': amzDate}if (contentType) headers['content-type'] = contentTypeconst signedNames = Object.keys(headers).sort()const canonicalHeaders = signedNames.map(k => `${k}:${String(headers[k]).trim()}\n`).join('')const signedHeaders = signedNames.join(';')const canonicalRequest = [method, endpoint.pathname, '', canonicalHeaders, signedHeaders, payloadHash].join('\n')46 unmodified lines47484950515253544 unmodified lines596061626364656646 unmodified linesendpoint.search = ''const payload = body == null ? Buffer.alloc(0) : Buffer.isBuffer(body) ? body : Buffer.from(body)// 与现有 server.js 的 aws4fetch 配置保持一致:R2 使用 UNSIGNED-PAYLOAD。const payloadHash = 'UNSIGNED-PAYLOAD'const date = new Date()const amzDate = date.toISOString().replace(/[:-]|\.\d{3}/g, '')const shortDate = amzDate.slice(0, 8)4 unmodified lines'x-amz-date': amzDate}if (contentType) headers['content-type'] = contentType// content-type 可以发送,但 aws4fetch 将其视为 unsignable header。const signedNames = Object.keys(headers).filter(name => name !== 'content-type').sort()const canonicalHeaders = signedNames.map(k => `${k}:${String(headers[k]).trim()}\n`).join('')const signedHeaders = signedNames.join(';')const canonicalRequest = [method, endpoint.pathname, '', canonicalHeaders, signedHeaders, payloadHash].join('\n')
fanqie/projects.js+4-2