Exemplo n.º 1
0
def get_url(profile, size):
    if size not in SIZES: raise Http404
    
    if profile.avatar_builtin:
        return builtin_avatar_url(profile.avatar, size)
    
    base = profile.avatar.replace('\\', '/')
    filename = "%s_%s.%s" % (base.split('/')[-1], size, EXTENSION)
    url = s3.get_url_from_bucket("avatar", filename)
    
    return url
Exemplo n.º 2
0
def save_slides_to_s3(task, slide_files):
    counter = 1

    num_slides = str(len(slide_files))

    s3_slide_urls = []

    for slide_file in slide_files:
        try:
            key = task.id + "/" + str(counter) + "_" + num_slides + ".png"
            print ("saving to s3 key=%s path=%s" % (key, slide_file))

            s3.save_filename_to_bucket(localsettings.S3_BUCKET_PPT, key, slide_file)

            s3_slide_urls.append(s3.get_url_from_bucket(localsettings.S3_BUCKET_PPT, key))
        except Exception, e:
            print e
            print ("save to s3 failed")
            raise e

        counter = counter + 1