1 Star 0 Fork 0

iStop/difyOSS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
saver.py 766 Bytes
一键复制 编辑 原始数据 按行查看 历史
iStop 提交于 2024-09-26 01:06 +08:00 . demo
import requests
class FileSaver:
def __init__(self, upload_url):
self.upload_url = upload_url
def save(self, filename, data, custom_param):
files = {'file': (filename, data)}
data = {'custom_param': custom_param}
response = requests.post(self.upload_url, files=files, data=data)
if response.status_code == 200:
print("File uploaded successfully:", response.json())
else:
print("Failed to upload file:", response.status_code, response.text)
# 示例用法
if __name__ == "__main__":
saver = FileSaver(upload_url="http://127.0.0.1:8000/upload/")
with open("path/to/your/local/file.txt", "rb") as f:
data = f.read()
saver.save("file.txt", data, "your_custom_param")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/istop/dify-oss.git
git@gitee.com:istop/dify-oss.git
istop
dify-oss
difyOSS
master

搜索帮助