Skip to content

Fix file upload path to serve media files from public directory - #14

Draft
enikqi with Copilot wants to merge 5 commits into
mainfrom
copilot/upload-complete-files
Draft

Fix file upload path to serve media files from public directory#14
enikqi with Copilot wants to merge 5 commits into
mainfrom
copilot/upload-complete-files

Conversation

Copilot AI commented Nov 6, 2025

Copy link
Copy Markdown

The upload API was saving files to /media/ at project root, but Next.js only serves static files from /public/. Uploaded files were inaccessible via URLs.

Changes

Upload API (app/api/upload/route.ts)

  • Changed upload directory from media/ to public/media/
  • Fixed file URL generation to return /media/filename

Media Listing API (app/api/media/route.ts) - new file

  • Returns all uploaded files with metadata (name, size, type, upload date)
  • Filters hidden files (.gitkeep)
  • Sorts by upload date descending

Upload Page (app/upload/page.tsx)

  • Loads and displays all uploaded files on mount, not just current session
  • Refactored file loading into reusable loadAllFiles() function
  • Added loading state indicator

Infrastructure

  • Created public/media/ directory with .gitkeep
  • Updated .gitignore to track directory structure but ignore uploaded files
// Before: files saved outside public directory
const uploadPath = join(process.cwd(), 'media')

// After: files accessible at /media/* URLs
const uploadPath = join(process.cwd(), 'public', 'media')

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkpoint.prisma.io

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

a je duke i pare files komplet tek ky site


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits November 6, 2025 07:41
…list all files

Co-authored-by: enikqi <10384338+enikqi@users.noreply.github.com>
Co-authored-by: enikqi <10384338+enikqi@users.noreply.github.com>
Co-authored-by: enikqi <10384338+enikqi@users.noreply.github.com>
Co-authored-by: enikqi <10384338+enikqi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add complete file upload feature to the site Fix file upload path to serve media files from public directory Nov 6, 2025
Copilot AI requested a review from enikqi November 6, 2025 07:53
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