Ejemplo n.º 1
0
def view_object(container_name, object_name):
    if 'url' in session and 'token' in session:
        down_obj = Objects.download(app.config['HOST'], 'GET','10', session['account'], container_name, object_name, session['temp_url_key'])
        down_obj = down_obj+'&inline'
        print 'DEBUG: views./account/' + container_name + '/download/' + object_name  +': ' + str(down_obj)
        result = {'status': down_obj}
        return jsonify(**result)
Ejemplo n.º 2
0
def delete_object(container_name, object_name):
    if 'url' in session and 'token' in session:
        del_obj = Objects.delete(session['url'], session['token'], container_name, object_name)
        print 'DEBUG: views./account/' + container_name + '/delete/' + object_name  +': ' + str(del_obj)
        result = {'status': del_obj}
        print '================================'+str(result)
        return jsonify(**result)
Ejemplo n.º 3
0
def container(container_name):
    if 'url' in session and 'token' in session:
        session['container'] = container_name
        try:
            output = swiftclient.get_container(url=session['url'], token=session['token'], container=container_name)
        except swiftclient.ClientException:
            return redirect(url_for('logout'))

        print 'DEBUG: views.container().swiftclient.get_container: '+str(output)
        container_info = output[0]
        container_info['x-container-bytes-used'] = float(container_info['x-container-bytes-used']) /(1024**3)

        for i in output[1]:
            i['last_modified'] = i['last_modified'][:10]+" "+i['last_modified'][11:16]
            i['content_type'] = i['content_type'].split('/')[1]

            temp_meta = Objects.read_temp_url(url=session['url'], token=session['token'], container=container_name, object=i['name'])
            i['temp_url'] = temp_meta[0]
            timestamp = temp_meta[1]
            if timestamp == False:
                i['temp_url_exp'] = '- '
            else:
                i['temp_url_exp'] = datetime.datetime.fromtimestamp(float(timestamp))

            print '###############################################################'
        obj_list = output[1]
        print type(output)
        print output[0]
        print output[1]
        cont_acl = Containers.check_read_acl(url=session['url'], token=session['token'], container_name=container_name)
        return render_template('container.html',
                               title='Container',
                               container_info=container_info,
                               obj_list=obj_list,
                               cont_acl=cont_acl)
        '''
        result = {'status': output}
        return jsonify(**result)
        cont_list = Containers().list(session['url'], session['token'])

        objs_list = Objects().list(session['url'], session['token'], container_name)
        if not objs_list:
            return render_template('account.html',
                               title='Account',
                               cont_list=cont_list)
        return render_template('account.html',
                               title='container',
                               objs_list=objs_list,
                               cont_list=cont_list)
        '''

    else:
        return redirect(url_for('login'))
Ejemplo n.º 4
0
def share_object(container_name, object_name, ttl):
    if 'url' in session and 'token' in session:
        temp_url_gen = Objects.temp_url_gen(session['url'], app.config['HOST'], 'GET',str(int(ttl)*3600), session['account'], container_name, object_name, session['temp_url_key'], session['token'])
        print 'DEBUG: views./account/' + container_name + '/' + object_name  +'/tempurl'+': ' + str(temp_url_gen)
        result = {'status': temp_url_gen}
        return jsonify(**result)
Ejemplo n.º 5
0
def share_object(container_name, object_name):
    if 'url' in session and 'token' in session:
        sh_obj = Objects.share(app.config['HOST'], 'GET','300', session['account'], container_name, object_name, session['temp_url_key'])
        print 'DEBUG: views./account/' + container_name + '/upload/' + object_name  +': ' + str(sh_obj)
        result = {'status': sh_obj}
        return jsonify(**result)