Skip to main content

Reusable upload handler for PDFs, DOCX, PPTX, ZIPs

Project description

🗂️ PYPYZUP

PYPYZUP is a lightweight, reusable Python module designed to streamline file uploads in document-based applications. It supports single and multiple file uploads of:

  • 📄 PDF (.pdf)
  • 📊 PowerPoint (.pptx)
  • 📝 Word (.docx)
  • 📈 Excel (.xlsx)
  • 🗜️ ZIP archives containing the above formats

PYZUP handles validation, safe extraction of ZIPs, automatic logging, and returns structured responses ideal for web APIs.


✅ Features

  • Upload single or multiple files
  • Validate ZIPs (must contain at least one allowed file)
  • Logs disallowed or corrupt files cleanly
  • Automatically creates target directories
  • Daily rotating logs (JSON compressed + console)
  • Structured response with "success" and "error" lists

🧩 How to Use

from werkzeug.datastructures import FileStorage
from pathlib import Path
from PYZUP import handle_uploaded_file

file_objs = request.files.getlist("files")  # Flask example
result = handle_uploaded_file(file_objs, Path("target_folder"))

if not result["success"]:
    return jsonify({"error": "No valid files processed", "details": result["error"]}), 415

return jsonify(result), 200

📥 Example Response

{
  "success": [
    {"filename": "report.pdf", "message": "report.pdf uploaded successfully."},
    {"filename": "slides.zip", "message": "ZIP extracted successfully."}
  ],
  "error": [
    {"filename": "malicious.exe", "message": "Allowed types: docx, pdf, pptx, xlsx, zip."}
  ]
}

⚙️ Flask Integration Example

from flask import Flask, request, jsonify
from pathlib import Path
from datetime import datetime
from PYZUP import handle_uploaded_file
from loguru import logger

app = Flask(__name__)
UPLOAD_ROOT = Path("uploaded_docs")

@app.route("/", methods=["POST"])
def upload():
    files = request.files.getlist("files")
    if not files:
        return jsonify({"error": "No file part in request."}), 400

    folder = datetime.utcnow().strftime("%Y%m%d_%H%M%S")
    target_dir = UPLOAD_ROOT / folder
    result = handle_uploaded_file(files, target_dir)

    return jsonify(result), 200

📁 Logging

Logs are stored in upload_logs/:

  • Daily log files: app_YYYYMMDD.log.zip
  • Console: logs shown at INFO level
  • File logs: full tracebacks and debugging info

🔒 Validation Rules

  • ✅ Allowed file types: .pdf, .docx, .pptx, .xlsx, .zip
  • ✅ ZIP must contain at least one allowed file
  • ⚠️ Unsupported ZIP contents are ignored and logged
  • ❌ Empty filenames or invalid formats are rejected

👨‍💻 Authors


📜 License

This project is licensed under the MIT License. See the LICENSE file for details.


📌 Status

✅ Actively maintained, production-ready, and easy to integrate into Flask apps or other backends.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyzup-0.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyzup-0.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file pyzup-0.1.1.tar.gz.

File metadata

  • Download URL: pyzup-0.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyzup-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7b7895b0c4a983b18a6657468c2f6a6b23bfecffa2ed4910dc27ce276dfddead
MD5 22f0dff1ba02e6cf0b55f7e8dc98fb78
BLAKE2b-256 def204264894dcfbce5c20cbef2b47a1efd5b5f9a024108678fb50b7f3ff3f00

See more details on using hashes here.

File details

Details for the file pyzup-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyzup-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyzup-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 44fc038dfd6df8d07bdd0a2f86c9e10b511dbe28541ec7b4789877514f2cf8ed
MD5 4512e2ff8b9f12dab3cdadecea56c3bb
BLAKE2b-256 6a90ec4debbc013df155c7872073449149d05f448fb337cdcf0e71f039b0d6c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page