这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@JeanMeijer
Copy link
Collaborator

@JeanMeijer JeanMeijer commented Nov 13, 2025

Description

Implements server-side file upload to AWS S3 using better-upload with better-auth integration. Supports up to 10 files, 100MB each, any content type.

Screenshots / Recordings

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • UI/UX update
  • Docs update
  • Refactor / Cleanup

Related Areas

  • Authentication
  • Calendar UI
  • Data/API
  • Docs

Testing

  • Manual testing performed
  • Cross-browser testing (if UI changes)
  • Mobile responsiveness verified (if UI changes)

Checklist

  • I’ve read the CONTRIBUTING guide
  • My code works and is understandable and follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in complex areas
  • I have updated the documentation
  • Any dependent changes are merged and published

Notes

Added /api/upload route, configured better-upload for S3, and enforced authentication. Updated .env.example and env/server.ts for AWS S3 credentials. Added better-upload dependencies.

By submitting, I confirm I understand and stand behind this code. If AI was used, I’ve reviewed and verified everything myself.


Want me to make any changes? Add a review or comment with @tembo and i'll get back to work!

tembo.io app.tembo.io


Summary by cubic

Adds an authenticated server-side S3 upload endpoint at /api/upload using better-upload. Supports up to 10 files (100MB each) with any content type.

  • New Features

    • Next.js POST route to upload files directly to AWS S3.
    • Session check via better-auth; returns 401 if not logged in.
    • Limits: up to 10 files, max 100MB per file.
  • Migration

    • Set AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_S3_BUCKET_NAME in .env (required in production).

Written for commit f1fbee7. Summary will update automatically on new commits.

Co-authored-by: Jean <jean@analoginterface.io>
@vercel
Copy link

vercel bot commented Nov 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
analog Error Error Nov 14, 2025 5:19pm

@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Collaborator Author

@JeanMeijer JeanMeijer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it now

Comment on lines 9 to 13
// Configure the upload router with S3
// The aws() client automatically reads from environment variables:
// - AWS_ACCESS_KEY_ID
// - AWS_SECRET_ACCESS_KEY
// - AWS_REGION
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all the comments, except for: // 100MB in bytes

Comment on lines 38 to 63
export async function POST(request: Request) {
// Get the session from better-auth
const headersList = await headers();
const session = await auth.api.getSession({
headers: headersList,
});

// Check if user is authenticated
if (!session?.user) {
return new Response(
JSON.stringify({
error: "Unauthorized",
message: "You must be logged in to upload files",
}),
{
status: 401,
headers: {
"Content-Type": "application/json",
},
},
);
}

// User is authenticated, proceed with upload
return uploadPOST(request);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead use:

import { RejectUpload, route, type Router } from '@better-upload/server';
import { aws } from '@better-upload/server/clients';

const auth = (req: Request) => ({ id: 'fake-user-id' });

const router: Router = {
client: aws(),
bucketName: 'my-bucket',
routes: {
images: route({
fileTypes: ['image/*'],
multipleFiles: true,
maxFiles: 4,
onBeforeUpload: async ({ req, files, clientMetadata }) => {
const user = await auth(req);

    if (!user) {
      throw new RejectUpload('Not logged in!');
    }
  },
}),

},
};

package.json Outdated
Comment on lines 30 to 34
],
"dependencies": {
"@better-upload/client": "^3.0.2",
"@better-upload/server": "^3.0.2"
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you fucking retarded, install it in apps/web

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

@JeanMeijer
Copy link
Collaborator Author

@tembo fix it based on the review and run format

@tembo
Copy link
Contributor

tembo bot commented Nov 14, 2025

@tembo fix it based on the review and run format

Done! I've addressed all the feedback:

  • Removed all comments except "// 100MB in bytes"
  • Refactored auth check to use onBeforeUpload hook with RejectUpload pattern as requested
  • Moved better-upload dependencies from root package.json to apps/web/package.json
  • Ran formatter on the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants