I am trying to create a signed url using the aws sdk, but I keep getting this type error.
Here’s my code:
import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
const s3Client = new S3Client({
region: 'auto',
endpoint: `https://${process.env.R2_ACCOUNT_ID!}.r2.cloudflarestorage.com`,
credentials: {
accessKeyId: process.env.R2_ACCESS_KEY!,
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
},
});
export async function getDownloadUrl(objectName: string) {
return await getSignedUrl(
s3Client,
new GetObjectCommand({
Bucket: process.env.R2_BUCKET_NAME,
Key: objectName,
}),
{ expiresIn: 3600 },
);
}
I’ve tried the following without any sucess:
return await getSignedUrl<GetObjectCommandInput, GetObjectCommandOutput>(
s3Client,
command,
{ expiresIn: 3600 } as RequestPresigningArguments
);
Any ideas? Thanks in advance!