示例#1
0
def add_audio_fms(request, page, time, duration):
    file_path = '%s/%s/%s/%d.flv' % (localsettings.FMS_STREAM_DIR, page.flowgram.id, page.id, time)
    
    if os.path.isfile(file_path):
        audio = models.Audio.objects.create(page=page, time=time, duration=duration)
        audio.path = file_path
        
        helpers.set_modified(page.flowgram)
        
        s3.save_filename_to_bucket(localsettings.S3_BUCKET_AUDIO, '%s.flv' % audio.id, file_path)
        
        return data_response.create(request.POST.get('enc', 'json'), 'ok', audio.id)
    else:
        log.debug('add_audio_fms called with page.id=%s, time=%d, and duration=%d but file_path=%s DNE' % \
                      (page.id, time, duration, file_path))
        
        return error_response.create(request.POST.get('enc', 'json'), 'flv does not exist.')
示例#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