Build a Free-Tier Image Pipeline with Alibaba Cloud OSS + CDN

Every side project eventually hits the same wall: where do uploaded images live? Putting them on your app server bloats the disk, burns bandwidth, and makes backups painful. Object storage plus a CDN in front is the standard answer. This tutorial walks through the whole pipeline with Alibaba Cloud OSS and CDN — from bucket creation to a working upload endpoint — with cost numbers you can reason about.

Why object storage instead of the server disk

Object storage (OSS) is built for exactly this job:

Step 1: Create a bucket

In the OSS console, create a bucket with these settings for a public-read, private-write pattern:

Step 2: Upload with the SDK

The Python SDK makes uploads a few lines:

import oss2

auth = oss2.Auth(access_key_id, access_key_secret)
bucket = oss2.Bucket(auth, endpoint, bucket_name)

bucket.put_object_from_file(
    f"uploads/{uuid4().hex}.jpg",
    "/tmp/source.jpg",
    headers={"Content-Type": "image/jpeg"}
)

Never expose the access key to the browser. Upload from your backend, or use STS temporary credentials for client-side uploads — OSS supports both cleanly.

Step 3: Put a CDN in front

Direct OSS URLs work, but for repeated views a CDN saves money and improves latency:

Step 4: What it costs

Rough order of magnitude for a hobby project:

Exact pricing moves with region and tier, so check the official calculator before launch. The key insight is architectural: your app server stays at a fixed size no matter how viral your images go.

Production notes

If you are comparing storage options or need a reference architecture for your project, I keep an independent summary of current cloud deals and setup notes at lieke-ai.com. Alibaba Cloud's official campaign page with current coupons: Alibaba Cloud coupons.