Last active
May 23, 2016 11:18
-
-
Save johanndiedrick/6150524 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MP3UploadHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.render('mp3upload.html') | |
def post(self): | |
mp3=self.request.files['mp3'][0] #mp3 post data from form | |
mp3body=mp3['body'] #body of mp3 file | |
mp3name = mp3['filename'] #mp3 name and path | |
conn = S3Connection('AWS_ACCESS_KEY_ID','AWS_SECRET_ACCESS_KEY') #amazon s3 connection | |
bucket = conn.create_bucket('foundsound_mp3') #bucket for images | |
k = Key(bucket) #key associated with image | |
k.key = mp3name #sets key to image name | |
k.set_metadata("Content-Type", "audio/mp3") #sets metadata for audio/mp3 | |
k.set_contents_from_string(mp3body) #puts mp3 data into s3 bucket | |
k.set_acl('public-read') #makes mp3 public | |
self.redirect("/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment