मुख्य सामग्री पर जाएँ
Skillpedia
API और सर्वर (backend)12k · #11419

django-storages-s3

यह क्या करती है

यह AI एजेंट को django-storages से AWS S3 पर Django के लिए फ़ाइल स्टोरेज सेट करने का मार्गदर्शन देती है। यह उन डेवलपर्स के लिए है जो अपलोड की गई फ़ाइलें और static एसेट क्लाउड पर रखना चाहते हैं।

कब इस्तेमाल करें

  • ✓जब आप Django की static और media फ़ाइलें S3 बकेट से परोसना चाहते हैं।
  • ✓जब आपको presigned डाउनलोड लिंक से साझा की गई निजी फ़ाइलें चाहिए।
  • ✓जब आप मौजूदा फ़ाइल अपलोड को अपना कोड दोबारा लिखे बिना S3 पर ले जाना चाहते हैं।

Skill का लिंक

https://github.com/Jeffallan/claude-skills/blob/main/skills/django-storages-s3/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/Jeffallan/claude-skills/blob/main/skills/django-storages-s3/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे Django यूज़र अपलोड और static फ़ाइलें S3 बकेट में ले जाइए, और निजी फ़ाइलें साइन किए गए लिंक के पीछे रखिए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट पैकेज इंस्टॉल करता है, क्रेडेंशियल और STORAGES सेटिंग्स सेट करता है, और सार्वजनिक को निजी स्टोरेज से अलग करता है। फिर वह अपलोड जाँचता है और mock स्टोरेज से टेस्ट करता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Django Storages S3

Senior Django specialist for production-grade file storage on AWS S3 via django-storages and boto3 — public and private media, static files, presigned URLs, and CloudFront.

When to Use This Skill

  • Serving static and/or media files from AWS S3 instead of the local filesystem
  • Configuring the Django 4.2+ STORAGES dict or legacy DEFAULT_FILE_STORAGE
  • Separating public (CDN-served) and private (presigned) file backends
  • Generating presigned download or direct browser-to-S3 upload URLs
  • Fronting S3 with CloudFront and writing a least-privilege IAM policy
  • Migrating local FileField/ImageField storage to S3 without code changes
  • Testing storage code without hitting S3

Core Workflow

  1. Install & register — pip install django-storages[s3] boto3; add "storages" to INSTALLED_APPS
  2. Configure credentials — Load from env vars or rely on an attached IAM role; never hardcode
  3. Wire the STORAGES dict — Set default (media) and staticfiles backends with separate location prefixes
  4. Add named backends — Split public vs. private buckets/ACLs as additional STORAGES entries when needed
  5. Verify & test — Run collectstatic, confirm uploads land in S3, and mock S3 in tests with InMemoryStorage or moto

Reference Guide

Load detailed guidance based on context:

Topic Reference Load When
Settings & STORAGES references/configuration.md Core settings, 4.2+ vs legacy, CloudFront
Custom backends references/custom-backends.md Public vs. private buckets, per-field storage
Presigned URLs references/presigned-urls.md Download links, direct browser uploads
Testing & IAM references/testing-storages.md Mocking S3, IAM policy, common pitfalls

Minimal Working Example

The snippet below demonstrates the core MUST DO constraints: env-loaded credentials, STORAGES dict, separate media/static locations, and default_acl=None on the media backend.

# settings.py
import os

AWS_STORAGE_BUCKET_NAME = os.environ["AWS_STORAGE_BUCKET_NAME"]
AWS_S3_REGION_NAME = os.environ.get("AWS_S3_REGION_NAME", "us-east-1")
AWS_S3_CUSTOM_DOMAIN = f"{AWS_STORAGE_BUCKET_NAME}.s3.{AWS_S3_REGION_NAME}.amazonaws.com"
# On EC2/ECS/Lambda, omit keys entirely — boto3 uses the attached IAM role.

STORAGES = {
    "default": {  # media uploads
        "BACKEND": "storages.backends.s3boto3.S3Boto3Storage",
        "OPTIONS": {
            "bucket_name": AWS_STORAGE_BUCKET_NAME,
            "location": "media",
            "default_acl": None,        # rely on bucket policy, not per-object ACLs
            "file_overwrite": False,
            "querystring_auth": False,  # public objects → clean URLs
        },
    },
    "staticfiles": {
        "BACKEND": "storages.backends.s3boto3.S3StaticStorage",
        "OPTIONS": {
            "bucket_name": AWS_STORAGE_BUCKET_NAME,
            "location": "static",
        },
    },
}

MEDIA_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/media/"
STATIC_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/static/"
# models.py — uploads go straight to S3 on save()
from django.db import models

class Document(models.Model):
    file = models.FileField(upload_to="docs/")  # uses STORAGES["default"]

Auditing an Existing Configuration

When reviewing a project that already uses S3 (not greenfield), walk this checklist — each item is a constraint below rephrased as "find X, confirm Y":

  1. Credentials — grep -rn "AWS_SECRET_ACCESS_KEY\|aws_secret" settings/ → confirm values come from os.environ/django-environ or an IAM role, never literals committed to the repo.
  2. ACLs — grep -rn "default_acl\|AWS_DEFAULT_ACL" . → on buckets created after April 2023, every value must be None. Any "public-read"/"private" will raise AccessControlListNotSupported; public access belongs in a bucket policy.
  3. Storage backend — confirm Django 4.2+ uses the STORAGES dict, not DEFAULT_FILE_STORAGE/STATICFILES_STORAGE (removed in Django 5.1, so silently ignored on 5.1/5.2/6.0); confirm the static class is S3StaticStorage, not a fabricated name.
  4. Locations — confirm default (media) and staticfiles have distinct location prefixes or buckets so collectstatic never collides with uploads.
  5. Region — confirm region_name (or the global AWS_S3_REGION_NAME) matches the bucket's real region and that AWS_S3_CUSTOM_DOMAIN includes the reg
अक्सर पूछे जाने वाले सवाल

क्या इसके लिए AWS क्रेडेंशियल चाहिए?

हाँ। यह उन्हें environment variables या जुड़े IAM role से लोड करती है, और कभी हार्डकोड नहीं करती।

क्या यह CloudFront सपोर्ट करती है?

हाँ। यह S3 के सामने CloudFront लगाना कवर करती है।

टेस्ट कैसे संभाले जाते हैं?

यह टेस्ट में in-memory स्टोरेज या moto से S3 का mock बनाती है, ताकि टेस्ट असली S3 तक न पहुँचें।

जानकारी

लेखक का मूल विवरण

Use when configuring Django to store static and media files on AWS S3 with django-storages. Invoke when working with the STORAGES setting, S3 buckets, presigned URLs, CloudFront, or boto3-backed file storage in settings.py. Configures the Django 4.2+ STORAGES dict, public/private custom backends, presigned GET/POST URLs, IAM policies, and S3 mocking for tests. Trigger terms: django-storages, S3, boto3, S3Boto3Storage, STORAGES, presigned URL, CloudFront, media files, collectstatic, AWS_STORAGE_BUCKET_NAME.

repo: Jeffallan/claude-skills

लोकप्रियता

GitHub स्टार
12k
रैंकिंग में स्थान
#11419
लाइसेंस
MIT
अपडेट की गई
30/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

angular-architect

12k

आपके एजेंट को standalone कॉम्पोनेंट, lazy-loaded रूटिंग, NgRx स्टेट, RxJS पैटर्न और परफ़ॉर्मेंस सुधार के साथ Angular 17 और नए ऐप बनाने में मदद करती है।

कोडिंगवेबसाइट और UI (frontend)

api-designer

12k

आपके एजेंट को REST या GraphQL API डिज़ाइन करने और OpenAPI 3.1 स्पेक लिखने में मदद करती है, जिसमें संसाधन, पेजिनेशन, एरर फ़ॉर्मेट और वर्ज़निंग के नियम हों।

कोडिंगAPI और सर्वर (backend)

architecture-designer

12k

आपके एजेंट को सिस्टम आर्किटेक्चर डिज़ाइन करने, पैटर्न और तकनीकों की तुलना करने, और हर चुनाव समझाने वाले Architecture Decision Records लिखने में मदद करती है।

कोडिंगसामान्य कोडिंग

atlassian-mcp

12k

MCP के ज़रिए Jira इश्यू खोजने और अपडेट करने, और Confluence पेज संभालने में मदद करती है, JQL और CQL क्वेरी, स्प्रिंट और दस्तावेज़ सिंक के साथ।

प्रोडक्टिविटीटास्क और प्रोजेक्ट

मिलती-जुलती skills