This is a FastAPI project for file management with user accounts. It includes features like user authentication, file upload/download, directory creation/deletion, and user activity tracking.
-
Clone the repository:
git clone https://github.com/your-username/fastapi-file-management.git cd fastapi-file-management
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Set up MongoDB:
- Create a MongoDB Atlas account and configure the connection string in
main.py
. - Update the
SECRET_KEY
and other configurations inmain.py
as needed.
- Create a MongoDB Atlas account and configure the connection string in
-
Run the FastAPI server:
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
-
Access the FastAPI Swagger documentation at http://localhost:8000/docs for API endpoints and testing.
- Login:
/token
- Obtain an access token for authentication. - Signup:
/signup
- Create a new user account. - Get Directories:
/directories
- Get a list of directories for the authenticated user. - Create Directory:
/create_directory
- Create a new directory for the authenticated user. - Upload File:
/upload
- Upload a file to the specified path for the authenticated user. - Download File:
/download
- Download a file from the specified path for the authenticated user. - Delete File:
/delete
- Delete a file from the specified path for the authenticated user. - Delete Directory:
/delete_directory
- Delete a directory and its contents for the authenticated user.
- FastAPI: https://fastapi.tiangolo.com/
- Pydantic: https://pydantic-docs.helpmanual.io/
- Passlib: https://passlib.readthedocs.io/
- pymongo: https://pymongo.readthedocs.io/
- uvicorn: https://www.uvicorn.org/