- Add Python script for downloading C4C attachments via OData and web scraping - Add Java wrapper for programmatic access with typed API - Add DSM upload utility for Synology NAS integration - Add CLAUDE.md documentation for future development - Add .gitignore for Python, Java, and sensitive files
43 lines
1.0 KiB
Python
43 lines
1.0 KiB
Python
import requests
|
||
import urllib3
|
||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||
|
||
NAS = "http://10.0.10.235:5000"
|
||
USER = "PLM"
|
||
PWD = "123456"
|
||
|
||
# 1) 登录
|
||
login_url = f"{NAS}/webapi/auth.cgi"
|
||
login_params = {
|
||
"api": "SYNO.API.Auth",
|
||
"version": "3",
|
||
"method": "login",
|
||
"account": USER,
|
||
"passwd": PWD,
|
||
"session": "FileStation",
|
||
"format": "sid",
|
||
}
|
||
r = requests.get(login_url, params=login_params, verify=False)
|
||
r.raise_for_status()
|
||
data = r.json()
|
||
sid = data["data"]["sid"]
|
||
|
||
# 2) 上传(SID 通过 cookie 传递)
|
||
upload_url = f"{NAS}/webapi/entry.cgi"
|
||
form = {
|
||
"api": "SYNO.FileStation.Upload",
|
||
"version": "2",
|
||
"method": "upload",
|
||
"path": "/Newgonow/AU-SPFJ",
|
||
"create_parents": "true",
|
||
"overwrite": "true",
|
||
}
|
||
with open("downloads/IMG_4307.mp4", "rb") as f:
|
||
files = {
|
||
"file": ("IMG_4307.mp4", f, "video/mp4")
|
||
}
|
||
r = requests.post(upload_url, data=form, files=files,
|
||
cookies={"id": sid}, verify=False)
|
||
|
||
print(r.status_code)
|
||
print(r.text) |