def deleteFile(fileId, filename): userId = RetrieveSessionDetails('userId') currentFolderId = RetrieveSessionDetails('currentFolderId') parentFolderId, parentfolderName = BusinessLayer.getParentFolderForFile( fileId, userId) print("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk: ", parentFolderId) print("llllllllllllllllllllllllllllllllllllllllll: ", parentfolderName) flag = BusinessLayer.RemoveExisitngFile(userId, currentFolderId, fileId, filename) if flag == True: try: path = BusinessLayer.getPathForFolder(userId, parentFolderId) target = os.path.join(APP_STORAGE_PATH, path) destination = "/".join([target, filename]) os.remove(destination) AddToSession('TotalSize', BusinessLayer.getTotalSize(userId)) except OSError: pass return redirect(url_for('index', folderId=currentFolderId))
def openfile(fileId, fileName): userId = RetrieveSessionDetails('userId') parentFolderId, parentfolderName = BusinessLayer.getParentFolderForFile( fileId, userId) print("///////////////////////////////////////", parentFolderId, parentfolderName) path = BusinessLayer.getPathForFolder(userId, parentFolderId) target = os.path.join(APP_STORAGE_PATH, path) mime = MimeTypes() url = urllib.request.pathname2url(target) mime_type = mime.guess_type(url) print(mime_type) return send_from_directory(directory=target, filename=fileName, mimetype=mime_type[0])