{"id":24158011,"url":"https://github.com/leuthra/file-uploader","last_synced_at":"2025-06-23T02:07:08.556Z","repository":{"id":259060437,"uuid":"864589196","full_name":"Leuthra/file-uploader","owner":"Leuthra","description":"With our global CDN, upload your files anywhere with exceptional speed and reliability.","archived":false,"fork":false,"pushed_at":"2024-10-21T15:52:15.000Z","size":417,"stargazers_count":16,"open_issues_count":0,"forks_count":14,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T23:25:06.569Z","etag":null,"topics":["expressjs","file-uploader","firebase"],"latest_commit_sha":null,"homepage":"https://cdn.romidev.tech","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Leuthra.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-28T16:11:11.000Z","updated_at":"2025-03-29T15:03:41.000Z","dependencies_parsed_at":"2024-10-22T07:10:45.294Z","dependency_job_id":null,"html_url":"https://github.com/Leuthra/file-uploader","commit_stats":null,"previous_names":["leuthra/file-uploader"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Leuthra/file-uploader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leuthra%2Ffile-uploader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leuthra%2Ffile-uploader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leuthra%2Ffile-uploader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leuthra%2Ffile-uploader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Leuthra","download_url":"https://codeload.github.com/Leuthra/file-uploader/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leuthra%2Ffile-uploader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261397374,"owners_count":23152489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expressjs","file-uploader","firebase"],"created_at":"2025-01-12T14:19:10.882Z","updated_at":"2025-06-23T02:07:03.504Z","avatar_url":"https://github.com/Leuthra.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CDN File Uploader\r\n\r\nA file uploader built with Node.js and Express that supports multiple file types, including images, documents, videos, presentations, and spreadsheets. The project includes MIME type validation to ensure only specific file types are uploaded. It also supports multiple storage options, including local storage, and Firebase Storage.\r\n\r\n## Features\r\n- Supports file upload for images, videos, gifs, documents (PDF, DOC, DOCX), presentations (PPT, PPTX), and spreadsheets (XLS, XLSX).\r\n- MIME type and extension validation for uploaded files.\r\n- Supports three different storage options: **Local**, and **Firebase**.\r\n- Configurable via environment variables.\r\n- **Vercel-ready**: This project can be easily deployed to Vercel for hosting.\r\n\r\n## Tech Stack\r\n- **Node.js**\r\n- **Express.js**\r\n- **Multer**: For handling file uploads.\r\n- **fs (File System)**: For file handling in the local filesystem.\r\n- **Firebase Admin SDK**: For Firebase storage (if using Firebase).\r\n- **dotenv**: For environment variable management.\r\n\r\n## Installation\r\n\r\n1. Clone this repository:\r\n   ```bash\r\n   git clone https://github.com/Leuthra/cdn-uploader.git\r\n   cd cdn-uploader\r\n   ```\r\n\r\n2. Install dependencies:\r\n   ```bash\r\n   npm install\r\n   ```\r\n\r\n3. Create a `.env` file to configure environment variables:\r\n   ```bash\r\n   touch .env\r\n   ```\r\n\r\n   **Example `.env` file:**\r\n   ```bash\r\n   # System environment variables\r\n   PORT=3000\r\n   PUBLIC_URL=http://localhost:3000\r\n   STORAGE=local  # Options: 'local', 'firebase'\r\n\r\n   # Firebase environment variables (if using Firebase)\r\n   FIREBASE_STORAGE_BUCKET=gs://your-firebase-bucket\r\n   PUBLIC_URL_FIREBASE=https://firebasestorage.googleapis.com/v0/b/your-firebase-bucket/o\r\n   ```\r\n\r\n4. Start the server:\r\n   ```bash\r\n   npm start\r\n   ```\r\n\r\n## Environment Variables\r\n\r\n| Variable Name                | Description                                              | Default Value    |\r\n| ---------------------------- | -------------------------------------------------------- | ---------------- |\r\n| `PORT`                       | Port number for the server                               | `3000`           |\r\n| `PUBLIC_URL`                 | Public URL for accessing the app                         | `http://localhost:3000` |\r\n| `STORAGE`                    | Storage option (`local`, `firebase`, or `drive`)         | `local`          |\r\n| `FIREBASE_STORAGE_BUCKET`     | Firebase storage bucket name (only if using Firebase)    | N/A              |\r\n| `PUBLIC_URL_FIREBASE`         | Public URL template for Firebase storage                 | N/A              |\r\n\r\n## Storage Options\r\n\r\nThis project supports three different storage options. You can choose the storage method by setting the `STORAGE` variable in your `.env` file to either `local`, `firebase`.\r\n\r\n### 1. Local Storage\r\nFiles are stored on the server's filesystem in the `uploads/` directory, which acts as local storage. Files will be served via the `/file` route, even if stored locally.\r\n\r\n### 2. Firebase Storage\r\nTo use Firebase Storage, set the `STORAGE` variable to `firebase` and configure the Firebase-specific environment variables such as `FIREBASE_STORAGE_BUCKET`. Uploaded files will still be accessed using the `/file` route.\r\n\r\nYou can find more detailed setup instructions in the [**FIREBASE.md**](./FIREBASE.md) file.\r\n\r\n## Usage\r\n\r\n1. **File Upload**: \r\n   Send a `POST` request to `/upload` with a file using the form field `fileInput`. The file will be saved in the specified storage method (local, Firebase, or Google Drive).\r\n\r\n   Example with **cURL**:\r\n   ```bash\r\n   curl -X POST http://localhost:3000/upload -F \"fileInput=@/path/to/your/file.jpg\"\r\n   ```\r\n\r\n2. **Allowed File Types**:\r\n   The following file types are allowed for upload:\r\n   - Images: `.jpeg`, `.jpg`, `.png`, `.gif`\r\n   - Documents: `.pdf`, `.doc`, `.docx`\r\n   - Presentations: `.ppt`, `.pptx`\r\n   - Spreadsheets: `.xls`, `.xlsx`\r\n   - Videos: `.mp4`, `.avi`, `.mov`, `.mkv`\r\n\r\n3. **Access Uploaded Files**:\r\n   All uploaded files, regardless of the storage method (local, Firebase, or Google Drive), will be accessible through the `/file` route. For example:\r\n\r\n   - **Local Storage**: `http://localhost:3000/file/your-file-name`\r\n   - **Firebase Storage**: `http://localhost:3000/file/your-file-name`\r\n   - **Google Drive**: `http://localhost:3000/file/your-file-name`\r\n\r\n## Hosting on Vercel\r\n\r\nThis project is fully compatible with **Vercel**. You can easily deploy it by pushing the repository to a GitHub repository and connecting it with Vercel. The configuration file `vercel.json` is included to handle deployment.\r\n\r\nOnce deployed, all files will be accessible via the `/file` route on your Vercel domain. The **uploads/** folder is used for local storage when the `STORAGE` is set to `local`.\r\n\r\n### Steps to Deploy on Vercel:\r\n\r\n1. Push your project to GitHub or GitLab.\r\n2. Go to [Vercel](https://vercel.com/), sign in, and create a new project by importing your repository.\r\n3. Set the required environment variables in the Vercel project settings.\r\n4. Deploy the project.\r\n\r\n## Project Structure\r\n\r\n```\r\n.\r\n├── config/                 # Configuration files (e.g., Firebase)\r\n├── controllers/            # Route controllers for handling requests\r\n├── middlewares/            # Custom middleware (e.g., IP handling, validation)\r\n├── public/                 # Public assets (e.g., HTML, CSS, JS files)\r\n├── routes/                 # Express routes\r\n├── uploads/                # Directory where uploaded files are stored (local storage only)\r\n├── utils/                  # Utility functions (e.g., helpers for file handling)\r\n├── .env                    # Environment variables configuration (to be created)\r\n├── .gitignore              # Git ignore file\r\n├── firebase.json           # Firebase configuration (if applicable)\r\n├── package.json            # Node.js dependencies and scripts\r\n├── README.md               # Project documentation\r\n├── server.js               # Main server file\r\n├── vercel.json             # Vercel deployment configuration\r\n├── FIREBASE.md             # Firebase setup instructions\r\n```\r\n\r\n## Dependencies\r\n\r\n- **express**: Web framework for Node.js.\r\n- **multer**: Middleware for handling `multipart/form-data`, used for uploading files.\r\n- **fs**: Node.js built-in module for interacting with the file system.\r\n- **firebase-admin**: For Firebase integration (if using Firebase storage).\r\n- **googleapis**: For Google Drive integration (if applicable).\r\n- **dotenv**: For environment variable management.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleuthra%2Ffile-uploader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleuthra%2Ffile-uploader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleuthra%2Ffile-uploader/lists"}