或将文件拖拽到这里(图片或zip包)

压缩包内的图片会被自动解压并上传,支持 JSON 提取经纬度

📋 已接收照片(按上传时间倒序)

加载中...

树莓派自动上传脚本 (Python)

将以下脚本保存为 upload.py,在树莓派上运行即可自动上传照片。支持单张图片或整个文件夹(会自动打包为ZIP)。

import requests import os import sys import zipfile import json from pathlib import Path API_URL = "https://worker.ultraman.tech/upload" # 替换为你的 Worker 地址 def upload_file(file_path, lat=None, lng=None): with open(file_path, 'rb') as f: files = {'file': (Path(file_path).name, f, 'image/jpeg')} data = {} if lat is not None and lng is not None: data = {'lat': lat, 'lng': lng} try: r = requests.post(API_URL, files=files, data=data) print(f" 上传成功: {file_path} -> {r.json()}") except Exception as e: print(f"上传失败: {file_path} - {e}") def upload_folder(folder_path): # 查找 JSON 文件获取经纬度 lat = lng = None json_file = None for root, dirs, files in os.walk(folder_path): for file in files: if file.lower().endswith('.json'): json_file = os.path.join(root, file) break if json_file: break if json_file: with open(json_file, 'r') as f: try: data = json.load(f) lat = data.get('lat') or data.get('latitude') lng = data.get('lng') or data.get('longitude') print(f" 从 {json_file} 提取经纬度: {lat}, {lng}") except: pass # 上传所有图片 for root, dirs, files in os.walk(folder_path): for file in files: if file.lower().endswith(('.jpg', '.jpeg', '.png', '.gif', '.bmp')): full_path = os.path.join(root, file) upload_file(full_path, lat, lng) if __name__ == "__main__": if len(sys.argv) < 2: print("用法: python upload.py <文件或文件夹路径>") sys.exit(1) target = sys.argv[1] if os.path.isfile(target): upload_file(target) elif os.path.isdir(target): upload_folder(target) else: print("路径无效")