Skip to content

Commit

Permalink
fix(s3): Include query params in signature
Browse files Browse the repository at this point in the history
  • Loading branch information
becem-gharbi committed Jan 14, 2024
1 parent 8b3a948 commit 8e86f0a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/drivers/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AwsClient } from "aws4fetch";
import crypto from "crypto";
import xml2js from 'xml2js'
import js2xml from 'jstoxml'
import { joinURL } from 'ufo'
import { joinURL, withQuery } from 'ufo'

if (!globalThis.crypto) {
// @ts-ignore
Expand Down Expand Up @@ -89,16 +89,13 @@ export default defineDriver((options: S3DriverOptions) => {

// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
async function _getKeys(base?: string) {
const request = await getAwsClient().sign(awsUrlWithoutKey, {
const url = withQuery(awsUrlWithoutKey, { prefix: base && normalizedKey(base) })

const request = await getAwsClient().sign(url, {
method: "GET",
});

return $fetch(request,
{
params: {
prefix: base && normalizedKey(base)
}
})
return $fetch(request)
.then((res) => {
let keys: Array<string> = []
xml2js.parseString(res, (error, result) => {
Expand Down

0 comments on commit 8e86f0a

Please sign in to comment.