Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for uploading, viewing, and deleting files from cloudflare #22

Merged
merged 18 commits into from
Nov 3, 2024

Conversation

Nyumat
Copy link
Member

@Nyumat Nyumat commented Nov 3, 2024

As referenced in (#21), this pull request is preparing us for the RAG implementation by supporting PDF CRUD (besides update) actions. It also includes several changes to improve the configuration, documentation, and database schema of the project.

API Implementation

  • GET /api/files - List all files in the Cloudflare R2 bucket
  • DELETE /api/files?id=123 - Delete a file with the id 123
  • GET /api/files/[id]/sign - Get the presigned URL for a file id (How we allow the client to view them)
  • POST /api/upload/pdf - Upload a PDF to the Cloudflare bucket and metadata to the database

UI/UX Changes

  • New page /upload - contains a form to upload a file and link to see all files
  • New page /files - a list of all files in the Cloudflare R2 bucket, including buttons to preview and delete them.
  • New button Sign Out - logs the current user out of the application.

Configuration Improvements:

  • Added a new .env.example file with placeholders for authentication secrets, database configuration, Pinecone, OpenAI, and Cloudflare R2 settings.

Documentation Updates:

  • Updated the README.md to include instructions for copying the .env.example file, starting the PostgreSQL database using Docker, and added a new troubleshooting section.
  • Added a table for all of our package.json scripts, with descriptions on what they do.
  • Troubleshooting steps for issues during project setup and installation.

Dependency Additions:

  • Added new dependencies @aws-sdk/client-s3, @aws-sdk/s3-request-presigner, and axios to package.json.
    • Axios allows us to easily monitor and visualize upload progress on the frontend (yay UX!)

Database Schema Changes:

  • Created a new course_materials table in the database with fields for id, title, fileName, fileUrl, uploadedAt, and description. (Currently, we can continue to refine this as we go!)

@Nyumat Nyumat added enhancement New feature or request critical Breaking change/feature advanced Great for experienced developers requires-officer Requires an officer input/aid labels Nov 3, 2024
@Nyumat Nyumat self-assigned this Nov 3, 2024
@Nyumat Nyumat linked an issue Nov 3, 2024 that may be closed by this pull request
@Nyumat
Copy link
Member Author

Nyumat commented Nov 3, 2024

Okay, I got most of the configuration and documentation stuff set up first to make this a smooth implementation.

@Nyumat
Copy link
Member Author

Nyumat commented Nov 3, 2024

Just finished implementing the backend methods utilizing Cloudflare to upload files to the bucket, view files in the bucket by generating a presigned URL and sending it to the client, and deleting files.

I'm now going to get the UI out for doing all of that, but in the Next.js client.

@Nyumat
Copy link
Member Author

Nyumat commented Nov 3, 2024

Okay the GitHub Actions workflow was failing due to me not including the PdfRecord type, but it should be good to go now after this next commit. Let's get the form implemented.

@Nyumat
Copy link
Member Author

Nyumat commented Nov 3, 2024

Okay, the feature is complete! That wasn't too bad.

:octocat:

@Nyumat Nyumat changed the title 🚀 feat: support for uploading, viewing, and deleting files from cloudflare R2 feat: support for uploading, viewing, and deleting files from cloudflare Nov 3, 2024
@Nyumat Nyumat merged commit d6d0a76 into main Nov 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
advanced Great for experienced developers critical Breaking change/feature enhancement New feature or request requires-officer Requires an officer input/aid
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow files to be uploaded from the client to the backend
1 participant