https://github.com/1999azzar/flask-simple-file-server
FSFS is a lightweight Flask-based file server, efficient and user-friendly solution for handling diverse file formats seamlessly.
https://github.com/1999azzar/flask-simple-file-server
api filemanagement filesystem flask-application python
Last synced: 6 months ago
JSON representation
FSFS is a lightweight Flask-based file server, efficient and user-friendly solution for handling diverse file formats seamlessly.
- Host: GitHub
- URL: https://github.com/1999azzar/flask-simple-file-server
- Owner: 1999AZZAR
- License: mit
- Created: 2024-01-05T19:30:00.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-06T14:41:43.000Z (over 1 year ago)
- Last Synced: 2025-02-01T12:45:50.372Z (8 months ago)
- Topics: api, filemanagement, filesystem, flask-application, python
- Language: Python
- Homepage:
- Size: 110 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Flask Simple File Server (FSFS)
## Table of Contents
- [Flask Simple File Server (FSFS)](#flask-simple-file-server-fsfs)
- [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [API Endpoints](#api-endpoints)
- [1. Upload File](#1-upload-file)
- [2. Download File](#2-download-file)
- [3. List Files](#3-list-files)
- [4. List Files with Specific File Format or Extension](#4-list-files-with-specific-file-format-or-extension)
- [5. Delete File](#5-delete-file)
- [Database Structure](#database-structure)
- [File Categories](#file-categories)
- [Flowchart](#flowchart)
- [Contributing](#contributing)
- [License](#license)## Introduction
Flask Simple File Server (FSFS) is a robust and user(admin)-friendly data application developed with Flask. Its primary purpose is to facilitate seamless file management, offering features like file upload, download, and categorization. Built on top of Flask, FSFS ensures a lightweight and efficient solution for organizing and accessing files.
## Features
1. **File Upload and Categorization:** Users can effortlessly upload files through the intuitive web interface. FSFS automatically categorizes files based on their extensions, making it easy to organize and locate them.
2. **File Download:**
- standard: Downloading files is straightforward. Users can retrieve files by specifying the filename, and FSFS provides a direct download link for quick access.
- enhanced: download endpoints for better user experience, supporting specific files, file formats, extensions, and bulk downloads.3. **File Listing:** FSFS maintains a detailed list of all uploaded files, including essential information such as filename, extension, category, and upload timestamp. This feature enhances visibility and allows users to review their uploaded content easily.
4. **File Categorization:** Uploaded files are intelligently organized into distinct folders according to their file types. This systematic categorization includes folders for images, videos, audio files, documents, compressed files, XML-related files, and a miscellaneous folder for unrecognized file types.
5. **SQLite Database Integration:** FSFS utilizes an SQLite database (`files.db`) to store and manage file metadata. The database ensures data persistence and enables efficient retrieval of file information.
6. **General Folder:** FSFS now includes a "GENERAL_FOLDER" for files with extensions not covered by existing categories.
7. **Delete:** delete specific file using the filename as the value for the `delete` endpoint make it easier to delete unwanted file.
## Installation
Setting up FSFS is a straightforward process. Follow these steps:
1. **Clone the Repository:**
```bash
git clone https://github.com/1999AZZAR/Flask-Simple-File-Server.git
cd Flask-Simple-File-Server
```2. **Install Dependencies:**
```bash
pip install -r requirements.txt
```3. **Run the Application:**
```bash
cd code
python the_server.py
```Access the server at [http://localhost:2500](http://localhost:2500) and [here](instruction.md) for more detailed instructions.
## Usage
FSFS offers a user-friendly experience for managing files. Users can utilize the provided API endpoints to interact with the file server. Refer to the [API Endpoints](#api-endpoints) section for detailed information.
## API Endpoints
### 1. Upload File
**Endpoint:** `/upload`
**Method:** `POST`
**Parameters:**- `file`: The file to be uploaded
- [example](code/example/api-call/file_upload.py)### 2. Download File
**Endpoint:** `/download`
**Method:** `GET`
**Parameters:**- `filename`: The name of the file to be downloaded
- `fileformat`: The file format for bulk download
- `extension`: The file extension for bulk download
- `all`: Download all files
- usage example `/download?fileformat=Image` will download all image files.
- [code example](code/example/api-call/file_download.py)### 3. List Files
**Endpoint:** `/list`
**Method:** `GET`
**Returns:** JSON array containing details of all uploaded files- [example](code/example/api-call/file_list.py)
### 4. List Files with Specific File Format or Extension
- To list files of a specific file format, use `/list?fileformat=`
- To list files with a specific extension, use `/list?extension=`For example:
- `/list?fileformat=Image` will list all image files.
- `/list?extension=.pdf` will list all PDF files.### 5. Delete File
**Endpoint:** `/delete/`
**Method:** `DELETE`
**Parameters:**- `filename`: The name of the file to be deleted
Usage example: `/delete/myfile.txt` will delete the file named "myfile.txt".
## Database Structure
FSFS employs an SQLite database (`files.db`) with a table named `files` to store file information. The table structure is as follows:
- `filename`: Name of the uploaded file
- `extension`: File extension
- `category`: File category (e.g., Image, Video)
- `upload_time`: Timestamp of when the file was uploaded## File Categories
Files are intelligently categorized into the following folders based on their extensions:
- `other_files`: Miscellaneous files
- `xml_files`: XML-related files
- `img_files`: Image files
- `video_files`: Video files
- `audio_files`: Audio files
- `document_files`: Document files
- `compressed_files`: Compressed files
- `null_files`: Files with no recognizable extension
- `general_files`: Files with unknown extensions## Flowchart
[](https://mermaid.live/edit#pako:eNqFll1zojAUhv_Kmdx4YzuCtlovdgcBv79a7WfcCxZSy6wQN0CnrvjfNwS1CghXhPO-J-dJwpCzRSa1CGqiJTPWHzDXFi6Agh_I34B4_i-4uvoRTiezeQgtrH4Q8w-U3u0VKYHtAtubopSWcI5pCCpP9gPmQqnNjWB7wmczYpXKUKtUTuyvxAtBwx3iQ-ARBtHMQtaEHNeLgq7hkBB03HM_jZVtHWM_hVv_nqx9LH5qhch7Ul0_wnawyojhE3inK4swT8idSIau4BLp5MsnrmdTV8hdIfdw13CtaG6a0HvH2fu4ZxHXt9838Twmr7SkbCNsfWF7GQ1DGGD-gLZAONF6jrHkyx5iMUjrKnXWjHgesUIY4e-3tPPJtgjnGWMxSOtKYNlcn2AxSOsaNQOHrySEKT6M064OcQkzViHc4_0w7RkHK254wNHzVB0IdWZ8ErFVIcz4YfNvYn8CjJiUWcI5E9s_xxr5HSzB4SvmmyOUeTxHYJo8GMLj4Vvw4siZN653bihIGSYRny4hPgnE5wzE53PEl-J6ScTclFES8fUS4qtAfMtAfDtHVJTigknG_JxxElJpXaJUxH8CFDWDU1EToFpx0RRobs4kBapfBNVj0HYWaDsB2ikumgLNzZmmQLsXQeO_l9LLAu0lQPvFRVOguTn3KdDBRdBBDDrMAh0mQEfFRVOguTkPKdDxRdBxDDrJAp0kQKfFRVOguTmPongrWoy3ppxQRF8yo4qSHdayw53scD87PMoOTzPDrcN_I47xpkHaxrf9vvGA-WZNdpFVleIbSB_qc50b5dM2RNzrsDYYf_r7m0SVv9sBtcoPZcUlaB9aC7V6fiRqLW979-62Ya8CFnHenHc3LuUfBA3cuLep8RxURg5hjmFbvKnaRnMskP9BHLJATT60DPZngRbujvuMwKezjWuips8CUkbB2uINgmYbvBdzDsG14b5RevqKmlv0hZqydHN915Abt7Ik3dbr0l0ZbVCzIV9XqtW7iiRznFu5Ut-V0T-RX7luVGtSpcrj9UqjXq-XEbFsn7JR3ACKPnD3HzYiWW4)
## Contributing
Contributions to FSFS are highly encouraged. Whether it's bug fixes, feature enhancements, or feedback, your input is valuable. Feel free to open issues or submit pull requests.
## License
FSFS is licensed under the [MIT License](LICENSE). Your usage and contributions are subject to the terms specified in the license.