File Upload Universal

Validate, scan, and upload files to AWS S3 and Cloudinary.

Updated Jun 7, 2024
One-click install
npx skills add https://github.com/ashishgurprit/ANLP_A3 --skill file-upload-universal
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: File Upload Universal
Source: https://github.com/ashishgurprit/ANLP_A3/tree/main/.claude.backup/skills/file-upload-universal
Command: npx skills add https://github.com/ashishgurprit/ANLP_A3 --skill file-upload-universal

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires fastapi, uvicorn, python-multipart, python-magic, boto3, cloudinary, pyclamd, pillow, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a robust and secure solution for handling file uploads, addressing common security vulnerabilities and offering flexible storage options to prevent vendor lock-in and optimize costs.

Core Features & Use Cases

  • Multi-Storage Support: Seamlessly uploads files to AWS S3 (for documents) and Cloudinary (for images/videos), leveraging the strengths of each.
  • Comprehensive Security: Implements multiple layers of validation including MIME type checking, magic byte verification, file size limits, malware scanning (ClamAV), and filename sanitization to prevent path traversal and XSS attacks.
  • Image Optimization: Automatically optimizes images via Cloudinary for faster loading and reduced bandwidth.
  • Use Case: An e-commerce platform can use this Skill to allow users to upload product images (which get optimized and served via CDN by Cloudinary) and product specification documents (stored cost-effectively and durably in S3).

Quick Start

Use the File Upload Universal skill to upload the file named 'report.pdf'.

Frequently Asked Questions about File Upload Universal

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I securely handle file uploads in FastAPI and prevent malware uploads?

Securely handle file uploads in FastAPI by validating MIME types, verifying magic bytes, enforcing size limits, and scanning with ClamAV. Filename sanitization prevents path traversal and XSS attacks during the upload process.

What is the best way to upload images to Cloudinary and documents to AWS S3?

Route images and videos to Cloudinary for automatic optimization, while storing documents durably and cost-effectively in AWS S3 to leverage the strengths of each storage provider.

How do I generate S3 presigned URLs for direct client-side file uploads?

Generate S3 presigned URLs to support direct client-side file uploads, offloading upload bandwidth from your FastAPI server directly to AWS S3 while maintaining secure access control.

Can I use python-magic and pyclamd to validate file types before uploading to AWS S3?

Yes, you can use python-magic to verify file magic bytes and pyclamd to scan for malware before transferring files to AWS S3 or Cloudinary, ensuring only safe and valid files are stored.

Why should I sanitize filenames when processing file uploads, and how does it prevent path traversal?

Sanitize filenames during file uploads to prevent path traversal and XSS attacks. Stripping dangerous characters and directory sequences ensures files are saved securely without overwriting critical system paths.