def handle_uploaded_file(f, user):
gcs_bucket = settings.GCS_BUCKET
user_key = md5.md5(str(user.username)).hexdigest()
# Sometimes things have paths in them? Windows used to do this.
name = f.name.split("/")[-1]
file_key = "%s/%s" % (user_key, name)
uri = boto.storage_uri("%s/%s" % (gcs_bucket, file_key), "gs")
uri.set_contents_from_string(f.read())
return "http://%s/%s" % (gcs_bucket, file_key)
评论列表
文章目录