Files
c4c-download/dsm-upload.py
afei A 929d3c2ec9 Initial commit: SAP C4C attachment downloader toolkit
- 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
2026-03-12 12:56:28 +08:00

43 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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)