Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pre merge iss6

  • Loading branch information...
commit a1fde12dbd43b3f75f2a7b1c55c4805a08b800ae 1 parent d750251
@drewverlee authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 petalapp/xtools.py
View
10 petalapp/xtools.py
@@ -3,23 +3,23 @@
import os.path
from flask import current_app as app
from werkzeug import secure_filename
-from config import AWS_SECRET_ACCESS_KEY,AWS_ACCESS_KEY_ID,S3_BUCKET,S3_UPLOAD_DIRECTORY
def s3_upload(source_file,acl='public-read'):
source_filename = secure_filename(source_file.data.filename)
source_extension = os.path.splitext(source_filename)[1]
destination_filename = uuid4().hex + source_extension
+ # Connect to S3
- # Connect to S3
- conn = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
- b = conn.get_bucket(S3_BUCKET)
+ conn = boto.connect_s3(app.config["AWS_ACCESS_KEY_ID"], app.config["AWS_SECRET_ACCESS_KEY"])
+ b = conn.get_bucket(app.config["S3_BUCKET"])
# Upload the File
- sml = b.new_key("/".join([S3_UPLOAD_DIRECTORY, destination_filename]))
+ sml = b.new_key("/".join([app.config["S3_UPLOAD_DIRECTORY"],destination_filename]))
sml.set_contents_from_string(source_file.data.readlines())
# Set the file's permissions.
sml.set_acl(acl)
return destination_filename
+
Please sign in to comment.
Something went wrong with that request. Please try again.