DigitalOcean Spaces has a limit of 500 req/sec per bucket and 1500 req/sec for all buckets.. so only
DigitalOcean Spaces has a limit of 500 req/sec per bucket and 1500 req/sec for all buckets.. so only R2 and S3 can compete on request rates
allHeaders: true into the aws block as well, next to signQuery: true=]





allHeaders: trueawssignQuery: true=]import {
PutObjectCommand,
S3Client
} from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
...
const s3 = new S3Client({ ... });
const cmd = new PutObjectCommand({
Bucket: c.env.BUCKET_NAME_VAULT_STORAGE,
Key: fileKey,
Metadata: {
test: 'hello',
},
ContentType: file.type,
ContentLength: file.size,
});
const url = await getSignedUrl(s3, cmd, { expiresIn: SIGNATURE_EXPIRATION_IN_SECONDS });
....(front end uploads to url)const r2 = new AwsClient({
accessKeyId: env.CF_ACCESS_KEY_ID,
secretAccessKey: env.CF_ACCESS_KEY_SECRET,
})
const url = new URL(`https://${env.BUCKET_NAME}.${env.CF_ACCOUNT_ID}.r2.cloudflarestorage.com`)
url.pathname = obj.path
url.searchParams.set('X-Amz-Expires', `${60 * 60 * 24 * env.STRUCTURE_EXPIRY}`)
const _signed = await r2.sign(new Request(url, {
method: 'GET',
contentDisposition: `attachment; filename="${obj.name}"`, // <------------------------ Something like this?
}), { aws: { signQuery: true } })
const signed = _signed.urlnew Request(url, {
headers: {
'content-disposition': `attachment; filename="${obj.name}"`
}
})const g_pdf = new PutObjectCommand({
Bucket: "fristroop",
Body: pdf.path,
Key: `halodergisi/dergiler/${pdf.filename}`,
});
await storage.send(g_pdf); const g_banner = new PutObjectCommand({
Bucket: "fristroop",
Body: banner.path,
Key: `halodergisi/thumbnails/${banner.filename}`,
ContentEncoding: banner.mimetype
});export const uploadFile = async (dest, file) => {
const command = new PutObjectCommand({
Bucket: "fristroop",
Body: file.path,
Key: `halodergisi/${dest}/${file.filename}`,
ContentType: file.mimetype,
});
await storage.send(command);
return command;
};
// router.js
const cmd_banner = await uploadFile("thumbnails", banner);
const cmd_pdf = await uploadFile("dergiler", pdf);
const model = await magazineModel.create({
id: v4(),
title,
description,
catId,
timestamp: Date.now(),
thumbnail: cmd_banner.input.Key,
file: cmd_pdf.input.Key,
});