Is this a clean way to handle S3 image uploads with better-auth in express?

Hey experts, I’m implementing direct-to-S3 uploads using presigned URLs. The flow is: Client requests an upload URL from /get-upload-url. Server validates the user, generates a presigned URL for S3, and returns it. Client uploads the file directly to S3. Client calls /confirm-upload to store the final image URL in the user’s profile. Is there any way to do thing same thing with on itself /api/auth/update-user? Current code
app.all("/api/auth/*splat", toNodeHandler(auth));

app.use(cookieParser());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

// 1. Generate presigned URL
app.post("/get-upload-url", async (req, res) => {
// auth check + getting upload url for amazon S3
});

// 2. Confirm upload and save URL
app.post("/confirm-upload", async (req, res) => {
// update user image
});
app.all("/api/auth/*splat", toNodeHandler(auth));

app.use(cookieParser());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

// 1. Generate presigned URL
app.post("/get-upload-url", async (req, res) => {
// auth check + getting upload url for amazon S3
});

// 2. Confirm upload and save URL
app.post("/confirm-upload", async (req, res) => {
// update user image
});
1 Reply
Sad man
Sad manOP5d ago
No description
No description
No description

Did you find this page helpful?