Are you visiting the direct path to a file? Theres no directory listing function so visiting a direc
Are you visiting the direct path to a file? Theres no directory listing function so visiting a directory or the root / wont work




aws4fetch to pull the files downnpm i aws4fetch. There are 30 other projects in the npm registry using aws4fetch.
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)aws4fetchnpm i aws4fetchconst 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,
});