report code changes by pankaj
This commit is contained in:
39
model/FolderAndFile.py
Normal file
39
model/FolderAndFile.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
from flask import current_app
|
||||
|
||||
|
||||
class FolderAndFile:
|
||||
|
||||
# -----------------------------
|
||||
# BASE FOLDER METHODS
|
||||
# -----------------------------
|
||||
@staticmethod
|
||||
def get_download_folder():
|
||||
folder = os.path.join(current_app.root_path, "static", "downloads")
|
||||
|
||||
if not os.path.exists(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
os.makedirs(folder, exist_ok=True)
|
||||
return folder
|
||||
|
||||
@staticmethod
|
||||
def get_upload_folder():
|
||||
folder = os.path.join(current_app.root_path, "static", "uploads")
|
||||
|
||||
if not os.path.exists(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
os.makedirs(folder, exist_ok=True)
|
||||
return folder
|
||||
|
||||
# -----------------------------
|
||||
# FILE PATH METHODS
|
||||
# -----------------------------
|
||||
@staticmethod
|
||||
def get_download_path(filename):
|
||||
return os.path.join(FolderAndFile.get_download_folder(), filename)
|
||||
|
||||
@staticmethod
|
||||
def get_upload_path(filename):
|
||||
return os.path.join(FolderAndFile.get_upload_folder(), filename)
|
||||
Reference in New Issue
Block a user