From cc42bcbbfb1e84a62560be5b1e77a7ad1df2efd4 Mon Sep 17 00:00:00 2001 From: "hanzhi.421" Date: Thu, 14 Aug 2025 16:03:08 +0800 Subject: [PATCH] feat: add message support network source --- veadk/utils/misc.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/veadk/utils/misc.py b/veadk/utils/misc.py index a9453369..1fe8f5a8 100644 --- a/veadk/utils/misc.py +++ b/veadk/utils/misc.py @@ -13,6 +13,7 @@ # limitations under the License. import time +import requests def read_file(file_path): @@ -28,6 +29,14 @@ def formatted_timestamp(): def read_png_to_bytes(png_path: str) -> bytes: - with open(png_path, "rb") as f: - data = f.read() + # Determine whether it is a local file or a network file + if png_path.startswith(("http://", "https://")): + # Network file: Download via URL and return bytes + response = requests.get(png_path) + response.raise_for_status() # Check if the HTTP request is successful + return response.content + else: + # Local file + with open(png_path, "rb") as f: + data = f.read() return data