OneManager-php icon indicating copy to clipboard operation
OneManager-php copied to clipboard

如何使用requests实现上传文件

Open Satoing opened this issue 2 years ago • 5 comments

我打算用python写一个上传文件的脚本,但是不是很懂文件上传是如何实现的。 每上传一个文件发起的请求如下: image 照着中间这个post请求,python代码如下:

import requests

headers = {
    'content-type': 'application/x-www-form-urlencoded',
    'cookie': ''
}
m = {
    'upbigfilename': 'c.jpg',
    'filesize': '84736',
    'filelastModified': 1664969090576,
    'proof_code': 'H51i/Zx6mj4=',
    "filesha1": "728c4e89a46bbdde64af8df27745056952f07dd4",
    'chunksize': 10485760,
    '_admin': ''
}
url = 'https://xxx/?action=upbigfile'
res = requests.post(url, headers = headers, data=m)

print(res.text)

但是最后返回的依然是HTML。请问上传文件该携带哪些数据?

Satoing avatar Jan 13 '23 04:01 Satoing

建议搭配RClone实现文件上传

Vincentzyx avatar Jan 13 '23 09:01 Vincentzyx

建议搭配RClone实现文件上传

emm,我认为没必要为了上传文件专门把云盘挂载到本地,不然还不如直接网页上传呢。

Satoing avatar Jan 14 '23 10:01 Satoing

建议搭配RClone实现文件上传

emm,我认为没必要为了上传文件专门把云盘挂载到本地,不然还不如直接网页上传呢。

不用挂载哇,有上传指令的,当cli用,挺好用的

Vincentzyx avatar Jan 14 '23 11:01 Vincentzyx

不用挂载哇,有上传指令的,当cli用,挺好用的

好,我看看。之前听说过没用过

Satoing avatar Jan 14 '23 11:01 Satoing

proof?你这是阿里的啊 应该是少了“x-requested-with: XMLHttpRequest”,另外content type我不知道form能不能行,你再试试

qkqpttgf avatar Feb 02 '23 02:02 qkqpttgf