This program implements a File Sharing System using Go
The following commands will clone the repository and change the directory into the project.
git clone https://github.com/Swetabh333/File-Sharing-App.git
cd File-Sharing-App
Edit the docker-compose.yaml file inside the 21BIT0278_BACKEND directory.
You need to set-up the following environment variables :
- JWT_SECRET : Enter your secret for json web tokens here
After installation and Environment setup it's time to run the program, you can do that with the following command :
docker compose up --build
It'll take a minute but this should start the application.
This project is a file-sharing platform that allows users to upload, manage, and share files. The system supports multiple users, file uploads, metadata management in PostgreSQL, and caching using Redis. It is built in Go with a focus on concurrency, performance optimization, and scalability.
- User Authentication & Authorization
POST /register: Register a new user with an email and password.
POST /login: Login to the system with email and password, generating a JWT token for authorization.
2. File Upload & Management
POST /upload: Upload a file to local storage. The file’s metadata is stored in PostgreSQL.
GET /files: Retrieve metadata for all files uploaded by the authenticated user.
3. File Retrieval & Sharing
GET /share/:file_id
: Share a public link for a specific file, enabling access through the generated URL.
You can paste the public_url returned from this endpoint and access the file.
- File Search GET /search: Search for files based on metadata like name, upload date, expects form data with name and date.
-
Caching Layer for File Metadata
Implements Redis for caching file metadata to reduce database load. The cache is invalidated when metadata is updated. -
Middleware for authentication
Middleware for route protection - /upload, /share, /search routes are protected via the middleware,only an authenticated user can access these. -
Background Job for File Deletion
A background worker periodically deletes expired files from storage and removes the associated metadata from the database.