Name:
[1982] Siddhi
Member:
37 months
Authored:
4 videos
Description:
I'm an entrepreneur from Chennai, India and I have my own company `Silver Stripe Software <http://www.silverstripesoftware.com>`_ where I develop tools for agile software development using Python and Django. My passion is in the startup ecosystem (especially in India), agile development and manageme ...
Using Amazon's S3 service with Django [ID:717] (1/1)
in series: More Django: Intermediate level Django screencasts
video tutorial by Siddhi, added 05/08
Name:
[1982] Siddhi
Member:
37 months
Authored:
4 videos
Description:
I'm an entrepreneur from Chennai, India and I have my own company `Silver Stripe Software <http://www.silverstripesoftware.com>`_ where I develop tools for agile software development using Python and ...
Our authors tell us that feedback from you is a big motivator. Please take a few moments to let them know what you think of their work.
Amazon's S3 service has been a hit with developers who need to store and serve large amounts of data in a scalable way. In this screencast we'll see how we can use S3 in a Django application.
We'll build a simple gallery app, but instead of storing the photos locally, we'll store them on S3 and then serve the photos directly from the S3 server. In the process, we'll learn the basics of using the boto library to interact with Amazon Web Services.
This screencast assumes you know the basics of Django. If you are new to Django, take a look at the Learn Django series on showmedo.
Links
boto: python library for Amazon web services Amazon S3 home page
# Create your views here.
import mimetypes
from django.shortcuts import render_to_response
from django import newforms as forms
from django.conf import settings
from boto.s3.connection import S3Connection
from boto.s3.key import Key
from models import PhotoUrl
class UploadForm(forms.Form):
file = forms.ImageField(label='Select photo to upload')
def index(request):
def store_in_s3(filename, content):
conn = S3Connection(settings.ACCESS_KEY, settings.PASS_KEY)
b = conn.create_bucket("siddhartafiles")
mime = mimetypes.guess_type(filename)[0]
k = Key(b)
k.key = filename
k.set_metadata("Content-Type", mime)
k.set_contents_from_string(content)
k.set_acl("public-read")
photos = PhotoUrl.objects.all().order_by("-uploaded")
if not request.method == "POST":
f = UploadForm()
return render_to_response("index.html", {"form":f, "photos":photos})
f = UploadForm(request.POST, request.FILES)
if not f.is_valid():
return render_to_response("index.html", {"form":f, "photos":photos})
file = request.FILES["file"]
filename = file["filename"]
content = file["content"]
store_in_s3(filename, content)
p = PhotoUrl(url="http://siddhartafiles.s3.amazonaws.com/" + filename)
p.save()
photos = PhotoUrl.objects.all().order_by("-uploaded")
return render_to_response("index.html", {"form":f, "photos":photos})
Got any questions?
Get answers in the ShowMeDo Learners Google Group.
Video statistics:
- Video's rank shown in the most popular listing
- Video plays: 2672 (since July 30th)
- Plays in last week: 16
- Published: 27 months ago
Thank-yous, questions and comments
If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?
You may also want to see our ShowMeDo Google Group to speak to our active users and authors.
All comments excluding tick-boxed quick-comments
That was a wonderful tutorial! You made my day. I hope you make more s3 videos.
Genius! Been looking for somewhere to explain how to integrate Amazon S3 and Django this was perfect.
Thank you! It's what I just needed :)
Gr8 tutorial Sid!
Please upload some more when you get some time!
Thanks
Very useful screencasts, thank you very much! I'm new to python and hooked on your tutorials. I will try posting them on my blog as well. Hope to see more of them.
Great demo. Very thorough giving a full picture. Would be nice to do a review at the end of the most critical elements.
Good enough to understand django/s3 usage together.
like it
very nice tutorial. keep up the good work.
Nice Tutorial
Thanks for showing how easy it is to use boto with s3.
Very informative! Thanks for taking the time to do this video.
You don't want to transfer the upload contents to your server then to S3. you should instead have the user's browser directly upload to S3.
See:
Thanks so much for this! Very easy to follow!
Do you know how to embed amazon store to our website?
Interesting video. I'm trying to understand the uses of Django with hosting and clouds.
Thanks Siddhi. Great job as always. How about some more intermediate Django vids?
Thunderbird 3: I love Firefox but it loads pages slowly. ,
What is the social philosophy of the document? ,
Great information! Thanks for your work!
that was awesome dude...keep it up, I'm new to django and I'm learning a lot thanks dude
Big thanks, it helps me alot :)
Hey Sid, That was an excellent intro to s3. I have bookmarked your screen cast for future reference. I really hope you find time to upload more AWS screen casts. Maybe something about hosting the Django app on EC2?
Once again, thank you!
Best,
Saravana
Thanks for all the comments. For anyone viewing this video, please keep in mind the changes you need to do for the latest Django version. You can find the changes in the comments.
@anonymous You can find out more about authentication in S3 here - http://docs.amazonwebservices.com/AmazonS3/latest/UsingAuthAccess.html
Hi Siddhi,
Awesomee...this is going to be of great help. I am trying to make an application which is running on Django and stores images on S3. ..almost the same thing which u did in your video. Only thing i want to know/figure out is how to add users on my website...i.e. All users can upload thier images in a one big bucket and user A can not access user Bs data. Any idea...suggestions..?
Fantastic your video about S3,
Its not for me now, but maybe in future.
Thank very much Siddhi
Santi from Spain
I am a fan of you
Nice Tutorial thx for everything
Great! Would love to see a part2 where you integrate the use of SimpleDB to this app.
Thanks Siddhi for your Django tutorials.
I've just finished the Django official tutorial and this is an excelent "desert".
Hey great video, I came here looking for s3 manipulation technicques but ended up watching it anyways cuz I like django too! thanks for sharing! :)
