file upload
This commit is contained in:
@@ -11,6 +11,8 @@ from app.api.services.subscriptions import SubscriptionsService
|
||||
from app.api.services.common_data import CommonDataService
|
||||
from app.api.services.genaratives import GenerativesService
|
||||
from app.api.services.comments import CommentsService
|
||||
from app.api.services.file_upload import FileUploadService
|
||||
|
||||
|
||||
#WEBSITE
|
||||
from app.api.services.website import WebsiteService
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
from flask import jsonify
|
||||
|
||||
from app.api.enums import KafkaMessage
|
||||
from app.api.services import MyProductsService
|
||||
from app.utils.logger import logger
|
||||
from app.api.services.base_service import BaseService
|
||||
from sqlalchemy import func, desc
|
||||
from app.extensions import db
|
||||
import os
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
|
||||
class FileUploadService(BaseService):
|
||||
UPLOAD_FOLDER = '/app/uploads' # '/uploads'
|
||||
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'}
|
||||
|
||||
@staticmethod
|
||||
def process_file_upload(upload_type: str, file, member_uid):
|
||||
|
||||
file_uid = "I GOT HERE "
|
||||
|
||||
try:
|
||||
|
||||
logger.info(f'POST CALLED 5 {file.filename}')
|
||||
save_path = FileUploadService.UPLOAD_FOLDER + "/" + "F000000000001"
|
||||
filename = secure_filename(file.filename)
|
||||
final_save_path = os.path.join(save_path, filename)
|
||||
logger.info(f'POST CALLED 6 {final_save_path}')
|
||||
|
||||
if not os.path.isdir(save_path):
|
||||
os.makedirs(save_path)
|
||||
|
||||
file.save(final_save_path)
|
||||
|
||||
response_data = {
|
||||
"file_uid": file_uid,
|
||||
}
|
||||
|
||||
return response_data
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred while getting dashboard data: {str(e)}", exc_info=True)
|
||||
return jsonify({"message": "Internal Server Error"}), 500
|
||||
Reference in New Issue
Block a user