Store the pictures on the file system and picture locations in the database.
Why? Because...
import urllib2
import cStringIO
from boto3.session import Session
from PIL import Image
aws_session = Session(
aws_access_key_id=settings.AWS_ACCESS_KEY_ID,
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
region_name=settings.AWS_DEFAULT_LAMBDA_REGION
)
s3_resource = aws_session.resource('s3')
im = Image.open(cStringIO.StringIO(urllib2.urlopen(image_url).read()))
w, h = im.size
w *= 0.5
h *= 0.5
im.thumbnail((w, h))
buf = cStringIO.StringIO()
im.save(buf, format="JPEG")
s3_resource.Object(bucket, filename).put(Body=buf.getvalue(), ACL='public-read')
```
I am reading images from a URL and compressing them and then saving to S3 using boto.
See how and where you want to store your images and just change the required line.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/530227c6-e9ad-4163-a15d-5afa9eab880a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bc43f2b0-9527-407b-b66f-774ad97d565c%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/81b29b5d-3c64-4501-84db-a08e319d409f%40googlegroups.com.