Skip to content

Instantly share code, notes, and snippets.

@ark4n631
ark4n631 / script.py
Last active April 23, 2024 19:48
Get a local copy of a file from django storages S3
from django.core.files import File
from django.core.files.storage import default_storage, FileSystemStorage
from django.conf import settings
from django.core.files.base import ContentFile
local_storage = FileSystemStorage()
local_storage.base_location = settings.MEDIA_ROOT
def get_local_file_from_object(obj):