构建请求 URL
(bucket: string, key?: string, queryParams?: Record<string, string>)
| 176 | |
| 177 | /** 构建请求 URL */ |
| 178 | private buildUrl(bucket: string, key?: string, queryParams?: Record<string, string>): string { |
| 179 | const proto = this.parsedEndpoint.protocol; |
| 180 | const host = this.getHost(bucket); |
| 181 | let path: string; |
| 182 | if (this.config.forcePathStyle) { |
| 183 | path = `/${bucket}`; |
| 184 | if (key) path += `/${awsUriEncode(key, false)}`; |
| 185 | } else { |
| 186 | path = key ? `/${awsUriEncode(key, false)}` : "/"; |
| 187 | } |
| 188 | |
| 189 | let url = `${proto}//${host}${path}`; |
| 190 | if (queryParams && Object.keys(queryParams).length > 0) { |
| 191 | const qs = Object.entries(queryParams) |
| 192 | .sort(([a], [b]) => a.localeCompare(b)) |
| 193 | .map(([k, v]) => `${awsUriEncode(k)}=${awsUriEncode(v)}`) |
| 194 | .join("&"); |
| 195 | url += `?${qs}`; |
| 196 | } |
| 197 | return url; |
| 198 | } |
| 199 | |
| 200 | /** AWS Signature V4 签名 */ |
| 201 | private async signRequest( |