← Back to Blog

Connecting Python Boto3 and FastAPI to QuixiCloud M-S3: A 3-Line Configuration Guide

By QuixiCloud Team•October 16, 2026
Connecting Python Boto3 and FastAPI to QuixiCloud M-S3: A 3-Line Configuration Guide

Connecting Python Boto3 and FastAPI to QuixiCloud M-S3: A 3-Line Configuration Guide

Python is the leading programming language for modern backend web development, asynchronous microservices, artificial intelligence (AI) pipelines, and distributed data processing. High-concurrency web frameworks like FastAPI and enterprise batteries-included frameworks like Django power thousands of mission-critical production backends globally.

When these backends require object storage to persist user-generated uploads, audio recordings, generative AI artifacts, or database snapshots, Amazon's official boto3 SDK is the universal industry standard.

The primary benefit for engineering teams: you do not need to install custom client libraries or refactor established application logic to escape hyperscaler egress tolls. Because QuixiCloud M-S3 implements complete standard S3 API compatibility, transitioning from AWS to QuixiCloud requires exactly 3 lines of configuration code.

In this technical guide, we detail how to configure boto3, construct a streaming upload endpoint in FastAPI, and generate cryptographically signed presigned URLs for client downloads.


The 3-Line Configuration Switch

Under legacy AWS S3 implementations, developers instantiate the boto3 client relying on default region endpoints:

# Legacy AWS S3 Initialization
import boto3
s3_client = boto3.client('s3')

To redirect your application's object storage pipeline to QuixiCloud M-S3, you simply supply the custom endpoint_url parameter:

# The QuixiCloud M-S3 Configuration (Just 3 Lines!)
import boto3

s3_client = boto3.client(
    's3',
    endpoint_url='https://s3.quixicloud.com',      # Line 1: Custom Endpoint
    aws_access_key_id='YOUR_QUIXICLOUD_KEY',       # Line 2: Your Key
    aws_secret_access_key='YOUR_QUIXICLOUD_SECRET', # Line 3: Your Secret
    region_name='us-east-1'
)

Every standard method in the boto3 client ecosystem—including upload_file(), upload_fileobj(), generate_presigned_url(), and list_objects_v2()—functions identically without modification.


Building an Asynchronous FastAPI Upload Endpoint

Let’s implement a production-ready FastAPI endpoint that streams file uploads directly to QuixiCloud M-S3 without caching massive payloads in server RAM:

from fastapi import FastAPI, UploadFile, File, HTTPException
import boto3
from botocore.exceptions import ClientError
import os

app = FastAPI(title="FastAPI + QuixiCloud M-S3 Service")

# Initialize client from environment variables
S3_BUCKET = os.getenv("S3_BUCKET_NAME", "production-app-uploads")

s3_client = boto3.client(
    's3',
    endpoint_url=os.getenv("S3_ENDPOINT_URL", "https://s3.quixicloud.com"),
    aws_access_key_id=os.getenv("S3_ACCESS_KEY_ID"),
    aws_secret_access_key=os.getenv("S3_SECRET_ACCESS_KEY"),
    region_name='us-east-1'
)

@app.post("/upload")
async def upload_asset(file: UploadFile = File(...)):
    """
    Streams incoming client file directly to QuixiCloud M-S3.
    """
    try:
        s3_client.upload_fileobj(
            file.file,
            S3_BUCKET,
            file.filename,
            ExtraArgs={'ContentType': file.content_type}
        )
        return {
            "status": "success",
            "message": f"Asset '{file.filename}' uploaded successfully to QuixiCloud M-S3!",
            "bucket": S3_BUCKET,
            "key": file.filename
        }
    except ClientError as err:
        raise HTTPException(status_code=500, detail=str(err))

Direct Client Downloads via Presigned URLs

Rather than proxying large binary downloads through your FastAPI web worker (which saturates application bandwidth and CPU cycles), generate temporary Presigned URLs. End-users download directly from QuixiCloud's high-speed storage network:

@app.get("/download-url/{filename}")
def generate_download_url(filename: str, expires_in: int = 3600):
    """
    Generates a secure, temporary pre-signed GET URL valid for 1 hour.
    """
    try:
        url = s3_client.generate_presigned_url(
            'get_object',
            Params={'Bucket': S3_BUCKET, 'Key': filename},
            ExpiresIn=expires_in
        )
        return {"filename": filename, "download_url": url}
    except ClientError as err:
        raise HTTPException(status_code=404, detail="Error generating secure URL")

Production Security: Environment Variable Configuration

Always maintain separation between code and credentials using a .env configuration:

# .env.production
S3_ENDPOINT_URL=https://s3.quixicloud.com
S3_ACCESS_KEY_ID=qx_live_83917401928471
S3_SECRET_ACCESS_KEY=qx_sec_92847192847192038471029
S3_BUCKET_NAME=production-app-uploads
S3_REGION=us-east-1

Load your configuration cleanly at runtime with python-dotenv:

from dotenv import load_dotenv
load_dotenv()

Why Developers Prefer QuixiCloud M-S3 for Python Backends

  1. Massive Cost Reduction: Individual developer plans start at just $4.99/month for 1 TB with 1.5 TB of included monthly egress.
  2. Bundled API Operations: 2.5 Million included API requests per month with 250 req/sec burst protection prevent crawler attacks from inflating your bill.
  3. Zero Architectural Debt: 100% S3 compatibility guarantees zero lock-in and zero friction across standard tooling.

Provision your Python application bucket today at aws.quixicloud.com.

Q

Written by QuixiCloud Team

The QuixiCloud Engineering Team is dedicated to building secure, scalable, and privacy-first cloud storage solutions.