修复头像和用户名bug,增加视频预览功能

Change-Id: I26087f826d29106a3db9428329946ff374c867bf
diff --git a/Merge/back_wzy/utils/Fpost.py b/Merge/back_wzy/utils/Fpost.py
index 2ffffbc..2ed295f 100644
--- a/Merge/back_wzy/utils/Fpost.py
+++ b/Merge/back_wzy/utils/Fpost.py
@@ -177,19 +177,39 @@
         """
         media_urls = []
         
+        # 支持的文件类型
+        ALLOWED_IMAGE_EXTENSIONS = {'.jpg', '.jpeg', '.png', '.webp'}
+        ALLOWED_VIDEO_EXTENSIONS = {'.mp4', '.mov', '.avi'}
+        ALLOWED_EXTENSIONS = ALLOWED_IMAGE_EXTENSIONS | ALLOWED_VIDEO_EXTENSIONS
+        
         for file in files:
             if file and file.filename:
                 # 生成安全的文件名
                 original_filename = secure_filename(file.filename)
                 # 生成唯一文件名避免冲突
                 unique_id = str(uuid.uuid4())
-                file_extension = os.path.splitext(original_filename)[1]
+                file_extension = os.path.splitext(original_filename)[1].lower()
+                
+                # 验证文件类型
+                if file_extension not in ALLOWED_EXTENSIONS:
+                    raise Exception(f"不支持的文件类型: {file_extension}")
+                
                 unique_filename = f"{unique_id}{file_extension}"
                 
-                # 读取文件内容
+                # 读取文件内容(对于大文件,分块读取)
                 file_content = file.read()
                 file.seek(0)  # 重置文件指针
                 
+                # 验证文件大小
+                file_size = len(file_content)
+                max_image_size = 32 * 1024 * 1024  # 32MB
+                max_video_size = 2 * 1024 * 1024 * 1024  # 2GB
+                
+                if file_extension in ALLOWED_IMAGE_EXTENSIONS and file_size > max_image_size:
+                    raise Exception(f"图片文件过大: {file_size / (1024*1024):.1f}MB,最大支持32MB")
+                elif file_extension in ALLOWED_VIDEO_EXTENSIONS and file_size > max_video_size:
+                    raise Exception(f"视频文件过大: {file_size / (1024*1024*1024):.1f}GB,最大支持2GB")
+                
                 # 保存到所有存储节点
                 success_count = 0
                 for node_path in self.storage_nodes: