https://github.com/analyticace/simple-file-sharing-api
This project is a simple file sharing API built using FastAPI. It provides endpoints to upload, download, and retrieve metadata about files.
https://github.com/analyticace/simple-file-sharing-api
api fastapi file-sharing links
Last synced: over 1 year ago
JSON representation
This project is a simple file sharing API built using FastAPI. It provides endpoints to upload, download, and retrieve metadata about files.
- Host: GitHub
- URL: https://github.com/analyticace/simple-file-sharing-api
- Owner: AnalyticAce
- Created: 2025-01-16T14:38:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-16T19:35:47.000Z (over 1 year ago)
- Last Synced: 2025-01-16T19:57:55.604Z (over 1 year ago)
- Topics: api, fastapi, file-sharing, links
- Language: HTML
- Homepage:
- Size: 74.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple-File-Sharing-API
This project is a simple file sharing API built using FastAPI. It provides endpoints to upload, download, and retrieve metadata about files. The uploaded files are stored in a folder, and metadata is managed in a JSON file.
## Features
- **File Upload**: Upload files to the server with metadata tracking.
- **File Download**: Securely download files by their unique ID.
- **Metadata Retrieval**: Access metadata for all files or a specific file.
- **Download Count Tracking**: Monitor how many times each file has been downloaded.
## Layout
- Upload Page #1

- Upload Page #2

- Download Page

## Technologies Used
- **Python**
- **FastAPI**: Web framework for building APIs.
- **JSON**: For metadata storage.
## Installation
1. Clone the repository:
```bash
git clone https://github.com/AnalyticAce/Simple-File-Sharing-API.git
cd Simple-File-Sharing-API
```
2. Set up a virtual environment (optional but recommended):
```bash
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install dependencies:
```bash
pip install -r requirements.txt
```
4. Run the server:
```bash
fastapi run app/main.py --host 0.0.0.0 --port 8080 --reload
```
The server will be accessible at `http://0.0.0.0:8080`.
## API Endpoints
### Upload File
**Endpoint**: `POST /file/upload/`
Uploads a file to the server.
**Request**:
- `file`: The file to upload (as `multipart/form-data`).
**Response**:
```json
{
"file_id": "",
"original_name": "",
"content_type": "",
"file_size": ,
"download_link": ""
}
```
### Download File
**Endpoint**: `GET /file/download/{file_id}`
Downloads a file by its unique ID.
**Response**:
- Returns the file as an attachment.
### Get Metadata for All Files
**Endpoint**: `GET /file/metadata/`
Retrieves metadata for all uploaded files.
**Response**:
```json
{
"": {
"original_name": "",
"content_type": "",
"file_size": ,
"download_count": ,
"download_link": ""
},
...
}
```
### Get Metadata for a Specific File
**Endpoint**: `GET /file/metadata/{file_id}`
Retrieves metadata for a specific file by its unique ID.
**Response**:
```json
{
"original_name": "",
"content_type": "",
"file_size": ,
"download_count": ,
"download_link": ""
}
```
## Contributing
1. Fork the repository.
2. Create a new branch for your feature:
```bash
git checkout -b feature/your-feature-name
```
3. Commit your changes:
```bash
git commit -m "Add your message here"
```
4. Push to your branch:
```bash
git push origin feature/your-feature-name
```
5. Open a pull request.
## License
This project is licensed under the MIT License. See the `LICENSE` file for details.
## Acknowledgments
- FastAPI documentation: https://fastapi.tiangolo.com/