Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@brunomichetti
Created July 11, 2022 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunomichetti/1f90592a64c89d6513fb67a39f3a334d to your computer and use it in GitHub Desktop.
Save brunomichetti/1f90592a64c89d6513fb67a39f3a334d to your computer and use it in GitHub Desktop.
# your models file
from django.db import models
from s3direct.fields import S3DirectField
from example_app.s3_files import get_object_key_from_url, get_presigned_url
class Example(models.Model):
image = S3DirectField(dest='example_destination')
@property
def presigned_image(self):
return get_presigned_url(get_object_key_from_url(self.image))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment