XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Fix copy_images, Add support .arc files

5676752c
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

3 个文件 +5 -6
Modified g4f/api/__init__.py +1 -2
@@ -10,7 +10,6 @@ from email.utils import formatdate
10 10 import os.path
11 11 import hashlib
12 12 import asyncio
13 from urllib.parse import quote_plus
14 13 from fastapi import FastAPI, Response, Request, UploadFile, Depends
15 14 from fastapi.middleware.wsgi import WSGIMiddleware
16 15 from fastapi.responses import StreamingResponse, RedirectResponse, HTMLResponse, JSONResponse
@@ -552,7 +551,7 @@ class Api:
552 551 HTTP_404_NOT_FOUND: {}
553 552 })
554 553 async def get_image(filename, request: Request):
555 target = os.path.join(images_dir, quote_plus(filename))
554 target = os.path.join(images_dir, os.path.basename(filename))
556 555 ext = os.path.splitext(filename)[1][1:]
557 556 stat_result = SimpleNamespace()
558 557 stat_result.st_size = 0
Modified g4f/image/copy_images.py +3 -3
@@ -60,8 +60,8 @@ async def copy_images(
60 60 ) as session:
61 61 async def copy_image(image: str, target: str = None) -> str:
62 62 """Process individual image and return its local URL"""
63 target_path = None
64 try:
63 target_path = target
64 if target_path is None:
65 65 # Generate filename components
66 66 file_hash = hashlib.sha256(image.encode()).hexdigest()[:16]
67 67 timestamp = int(time.time())
@@ -88,7 +88,7 @@ async def copy_images(
88 88 f"{extension}"
89 89 )
90 90 target_path = os.path.join(images_dir, filename)
91
91 try:
92 92 # Handle different image types
93 93 if image.startswith("data:"):
94 94 with open(target_path, "wb") as f:
Modified g4f/tools/files.py +1 -1
@@ -78,7 +78,7 @@ from ..providers.asyncio import to_sync_generator
78 78 from ..errors import MissingRequirementsError
79 79 from .. import debug
80 80
81 PLAIN_FILE_EXTENSIONS = ["txt", "xml", "json", "js", "har", "sh", "py", "php", "css", "yaml", "sql", "log", "csv", "twig", "md"]
81 PLAIN_FILE_EXTENSIONS = ["txt", "xml", "json", "js", "har", "sh", "py", "php", "css", "yaml", "sql", "log", "csv", "twig", "md", "arc"]
82 82 PLAIN_CACHE = "plain.cache"
83 83 DOWNLOADS_FILE = "downloads.json"
84 84 FILE_LIST = "files.txt"