Ejemplo n.º 1
0
Archivo: app.py Proyecto: pnjha/DropBox
def createfolder():

    if request.method == "POST":
        
        userId = RetrieveSessionDetails('userId')
        currentFolderId = RetrieveSessionDetails('currentFolderId')

        foldername = request.form.get('folder')
        
        folderobj = BusinessLayer.createfolder(userId,currentFolderId,foldername)
        
        if folderobj != None:

            UserData = BusinessLayer.getFolderContents(userId,currentFolderId)
            path = BusinessLayer.getPathForFolder(userId,currentFolderId)

            print("APP_STORAGE_PATH: ",APP_STORAGE_PATH)
            target = APP_STORAGE_PATH+path
            
            destination = target+foldername
            
            if not os.path.isdir(destination):
                    os.mkdir(destination)

            return redirect(url_for('index',folderId = currentFolderId))            
            
        else:    

            return render_template("404.html")    
    else:
        return render_template("404.html")     
Ejemplo n.º 2
0
def index(folderId):

    userId = RetrieveSessionDetails('userId')
    AddToSession('currentFolderId', folderId)
    foldername = BusinessLayer.getPathForFolder(userId, folderId)
    foldername = foldername[:-1]
    AddToSession('currentFolderName', foldername)
    #keyToAdd = 'PFDEL_'+foldername
    #AddToSession('directory_home',foldername)

    UserData = BusinessLayer.getFolderContents(userId, folderId)
    UserData["sourceParameter"] = "NotsearchIndex"
    UserData["AllFilesource"] = "NotAllFileSource"
    # if BusinessLayer.getHomeFolderId(folderId) == folderId:
    #     UserData["homefolder"] = "home"
    # else:
    #     UserData["homefolder"] = "nothome"

    userclassInstance = UserClass()
    userclassInstance.setUserDetails(RetrieveSessionDetails('userId'),
                                     RetrieveSessionDetails('userName'),
                                     "passwd", "name", "email", "phone")
    userclassInstance.setCurrentFolderId(
        RetrieveSessionDetails('currentFolderId'))
    userclassInstance.setCurrentFolderName(
        RetrieveSessionDetails('currentFolderName'))
    userclassInstance.setHomeFolderId(RetrieveSessionDetails('homeFolderId'))

    UserData['TotalSize'] = RetrieveSessionDetails('TotalSize')
    UserData['UserDetails'] = userclassInstance
    return render_template('index.html', **UserData)
Ejemplo n.º 3
0
def upload():

    if request.method == "POST":

        userId = RetrieveSessionDetails('userId')
        currentFolderId = RetrieveSessionDetails('currentFolderId')

        print("userId: ", userId)
        print("currentFolderId: ", currentFolderId)

        path = BusinessLayer.getPathForFolder(userId, currentFolderId)

        print("path: ", path)
        target = os.path.join(APP_STORAGE_PATH, path)
        print("Target path: ", target)

        if not os.path.isdir(target):
            os.mkdir(target)

        for upload in request.files.getlist("file"):

            filename = upload.filename
            destination = "/".join([target, filename])
            upload.save(destination)

            file_size = os.stat(destination).st_size
            print("file size: ", file_size)

            fileObj = FileClass()
            fileObj.setFileDetails(46, filename, 0, file_size, userId,
                                   currentFolderId)

            fileObj = BusinessLayer.createFile(fileObj, userId,
                                               currentFolderId)
            print(fileObj)

        UserData = BusinessLayer.getFolderContents(userId, currentFolderId)

        AddToSession('TotalSize', BusinessLayer.getTotalSize(userId))

        return redirect(url_for('index', folderId=currentFolderId))

    else:
        return render_template("404.html")
Ejemplo n.º 4
0
Archivo: app.py Proyecto: pnjha/DropBox
def index(folderId):

    userId = RetrieveSessionDetails('userId')
    AddToSession('currentFolderId',folderId)
    foldername = BusinessLayer.getPathForFolder(userId,folderId)
    foldername = foldername[:-1]
    AddToSession('currentFolderName',foldername)
    #keyToAdd = 'PFDEL_'+foldername
    #AddToSession('directory_home',foldername)

    UserData = BusinessLayer.getFolderContents(userId, folderId)

    userclassInstance = UserClass()
    userclassInstance.setUserDetails(RetrieveSessionDetails('userId'),RetrieveSessionDetails('userName'),"passwd","name","email","phone")
    userclassInstance.setCurrentFolderId(RetrieveSessionDetails('currentFolderId'))
    userclassInstance.setCurrentFolderName(RetrieveSessionDetails('currentFolderName'))
    userclassInstance.setHomeFolderId(RetrieveSessionDetails('homeFolderId'))

    UserData['TotalSize'] = RetrieveSessionDetails('TotalSize')
    UserData['UserDetails'] = userclassInstance
    return render_template('index.html', **UserData)