예제 #1
0
파일: views.py 프로젝트: tarun0409/dropbox
def delete_file(id=None):
    db_obj = DropBoxDB("praveen", "S@gem0de")
    print("In delete file{0}".format(id))
    print("Getting file path in delete file {0}".format(
        db_obj.get_file_path(id)))
    target = "/".join([APP_ROOT, "uploaded"])
    target = "/".join([target, session['email']])
    target = "/".join([target, db_obj.get_file_path(id)])
    print("Deleting file: {0}".format(target))
    db_obj.delete_file(id)
    os.remove(target)
    return "Dsadsadas"
예제 #2
0
파일: views.py 프로젝트: tarun0409/dropbox
def download():
    db_obj = DropBoxDB("praveen", "S@gem0de")
    if (request.method == "POST"):
        #if(True):
        print("In dload file")
        f_name = request.form["f_name"]
        #return f_name
        file_path = db_obj.get_file_path(int(f_name))
        print("fp is ", file_path)
        target = "/".join([APP_ROOT, "uploaded"])
        dest_path = request.form["dest_path"]
        print("In download: " + dest_path)

        if dest_path.find("@") != -1:
            print("dsadsadsadsa")
            target = "/".join([target, dest_path])
        else:
            target = "/".join([target, session['email']])
        final_path = "".join([target, file_path])

        # print("received dest_path ",dest_path)
        # full_path = ""
        # if(dest_path!=""):
        #     full_path = db_obj.get_folder_path(int(dest_path))
        # print("after query completes ")
        # #f_name = request.args.get('f_name')
        # print("please dload ",f_name," from ",full_path)
        # print("app root is ",APP_ROOT)
        # target = "/".join([APP_ROOT,"uploaded"])

        # print(target)
        # target = "/".join([target,session['email']])
        # # if(full_path!="/"):
        # target = "".join([target,full_path])
        # final_path = "/".join([target,f_name])

        print "For download: ", final_path
        #return final_path
        try:
            return send_file(final_path, as_attachment=True)
        except Exception as e:
            print e
            #send_from_directory(directory=target, filename=f_name)
        #print("In move folder src:{0} dest{1}".format(src_id,dest_id))
    return "dummy val"
예제 #3
0
파일: views.py 프로젝트: tarun0409/dropbox
def move():
    if (request.method == "POST"):
        db_obj = DropBoxDB("praveen", "S@gem0de")
        print("In move file")
        src_id = request.form["src_id"]
        dest_id = request.form["dest_id"]
        print("In move folder src:{0} dest{1}".format(src_id, dest_id))
        src_path = db_obj.get_file_path(src_id)
        print("src id ", src_path)
        dest_path = db_obj.get_folder_path(dest_id)
        print("destn path ", dest_path)
        target = "/".join([APP_ROOT, "uploaded"])
        target = "/".join([target, session['email']])
        full_src_path = "".join([target, src_path])
        full_dest_path = "".join([target, dest_path])
        print("full src path:", full_src_path)
        f_name = full_src_path.split('/')
        x = f_name[len(f_name) - 1]
        print(x)
        full_dest_path = "/".join([full_dest_path, x])
        print("full destn path:", full_dest_path)
        os.rename(full_src_path, full_dest_path)
        db_obj.move_file(src_id, dest_id)
        return "dsadsadsa"