← 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 programming language of choice for modern backend engineering, artificial intelligence (AI) pipelines, data science, and asynchronous web microservices. Frameworks like FastAPI and Django power thousands of mission-critical applications across India.

When these applications need to store user-uploaded files, invoice PDFs, machine learning models, or profile avatars, the standard library used is Amazon's official boto3 SDK.

The great news for Python developers: you do not need to learn a new SDK or refactor your application architecture to escape AWS’s punishing egress fees. Because QuixiCloud M-S3 implements full S3 API compatibility, switching from AWS to QuixiCloud requires just 3 lines of configuration code.

In this technical guide, we walk through configuring boto3, building an asynchronous file upload endpoint in FastAPI, and generating secure presigned URLs for client downloads.


The 3-Line Configuration Switch

In standard AWS S3 setups, you initialize the boto3 client with default credentials:

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

To switch your entire application to QuixiCloud M-S3, you simply provide the endpoint_url pointing to QuixiCloud’s sovereign endpoint:

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

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

That’s it! Every standard boto3 method—upload_file(), download_fileobj(), generate_presigned_url(), and list_objects_v2()—works identically out of the box.


Building a Production FastAPI File Upload Service

Let’s implement a modern, asynchronous FastAPI application that handles streaming file uploads to QuixiCloud M-S3 without loading massive files into server memory:

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

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

# 1. Initialize S3 client using environment variables
S3_BUCKET = os.getenv("S3_BUCKET_NAME", "app-user-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='in-west-1'
)

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

Generating Secure Presigned URLs for Direct Downloads

Instead of routing heavy file downloads through your Python application server (which burns server RAM and bandwidth), generate temporary Presigned URLs. End-users download directly from QuixiCloud at high gigabit speeds:

@app.get("/download-url/{filename}")
def get_secure_download_url(filename: str, expires_in: int = 3600):
    """
    Generates a temporary signed URL valid for 1 hour.
    """
    try:
        presigned_url = s3_client.generate_presigned_url(
            'get_object',
            Params={'Bucket': S3_BUCKET, 'Key': filename},
            ExpiresIn=expires_in
        )
        return {"filename": filename, "download_url": presigned_url}
    except ClientError as e:
        raise HTTPException(status_code=404, detail="Object not found or error generating URL")

Best Practice: Configuring Clean Environment Variables

Never hardcode access keys in your Python source files. Use a .env file with python-dotenv:

# .env
S3_ENDPOINT_URL=https://s3.quixicloud.com
S3_ACCESS_KEY_ID=qx_live_948f92847291048
S3_SECRET_ACCESS_KEY=qx_sec_a849f829103982019482
S3_BUCKET_NAME=my-production-bucket
S3_REGION=in-west-1

Load your configuration cleanly in your application startup:

from dotenv import load_dotenv
load_dotenv()

Why Python Developers in India Love QuixiCloud M-S3

  1. Sub-15ms Latency: Because our sovereign data centers are located in Mumbai and Noida, boto3 API operations complete up to 4× faster than calls to overseas US/EU buckets.
  2. Predictable INR Pricing: Individual tiers start at just ₹399/month for 1 TB with 1.5 TB of included monthly egress.
  3. No Code Rewrite: Transitioning existing Django, Flask, or FastAPI applications takes less than 5 minutes.

Deploy your first Python S3 bucket today at aws.quixicloud.com.

Q

Written by QuixiCloud Team

The QuixiCloud India Engineering Team is dedicated to building secure, scalable, and privacy-first cloud storage solutions tailored for Indian businesses and users.