DEV Community

Mmm
Mmm

Posted on

Retro File Upload Bot: Automate Vintage File Uploads with Python

Ever had to manually upload files to a retro-style website that responds with a 404 error after 3 tries? I’ve been there—uploading photos to a vintage file service for a side project felt like playing a game of "find the missing token" where the server would reset your session after 5 failed attempts. Manual uploads were slow, error-prone, and made me question if I should even be doing this in the first place.

That’s why I built Retro File Upload Bot—a tiny Python script that automates uploads to retro-themed file services with token-based authentication. These services (like the one I used for a retro-themed dev project) often have quirks: they require specific tokens, handle file size limits, and reset sessions after repeated failures. Instead of wrestling with browser-based forms or CLI tools, this script handles the entire workflow in under 10 lines of code. It’s perfect for developers who need to upload files to vintage APIs without the friction of manual retries.

Here’s how it works in practice. The script uses requests to send files to a retro API endpoint while managing tokens and error states transparently. No web scrapers, no complex authentication flows—just clean, reliable uploads:

import requests

RETRO_API_URL = "https://retro-service.example.com/upload"
TOKEN = "your_token_here"  # Replace with your service token

def upload_file(file_path):
    with open(file_path, "rb") as f:
        response = requests.post(
            RETRO_API_URL,
            files={"file": f},
            headers={"X-Token": TOKEN}
        )
    return response.status_code
Enter fullscreen mode Exit fullscreen mode

This snippet handles the core logic: it opens a file, sends it via files parameter, and includes the token in the X-Token header. The response status code tells you if the upload succeeded (200) or failed (e.g., 401 for invalid tokens).

For real-world use, I added error handling and retry logic. Here’s how you’d run it with a safety net:

if __name__ == "__main__":
    MAX_RETRIES = 3
    for attempt in range(MAX_RETRIES):
        try:
            status = upload_file("photo.jpg")
            print(f"Upload successful! Status: {status}")
            break
        except Exception as e:
            print(f"Attempt {attempt+1} failed: {e}")
            if attempt == MAX_RETRIES - 1:
                print("Max retries reached. Aborting.")
Enter fullscreen mode Exit fullscreen mode

This version retries failed uploads up to 3 times—ideal for retro APIs that reset sessions after errors. You can tweak MAX_RETRIES based on your service’s behavior.

Why is this useful? Retro file services often require token-based auth and have strict file size limits (e.g., 5MB max). Manually checking for errors or restarting sessions is tedious. This script turns a 5-minute manual process into a 2-second automation, while handling edge cases like token expiration or network timeouts. It’s especially valuable for developers working with legacy APIs or vintage web services where standard tools don’t fit.

I built this for a personal project where I needed to upload test files to a retro-themed service without browser dependencies. The simplicity means you can integrate it into your CI/CD pipelines or scripts without learning new frameworks. Plus, it’s 100% open-source—no hidden dependencies beyond standard libraries.

If you’re automating similar file uploads for retro APIs, I’d love to hear your approach. Grab the full script here: https://7982180762074.gumroad.com/l/gfsle

What’s the smallest automation you’ve done that saved you time? I’m curious to see how you’d solve this problem in your workflow.

Top comments (0)