Hello:) I’ve gone through your code and the documentation at https://www.mediawiki.org/wiki/API:Upload#Chunked_uploading several times to try and understand why all the chunks are not being uploaded and this is what I think is the problem- You are not passing in the “offset” which will determine the starting point of the next chunk. So it’ll always be zero, which is the offset of the first chunk.
When you upload the first chunk, the response will include the starting point of the next chunk, so I passed this in the next chunk and it worked, i.e
#parameters for the first chunk
PARAMS_4 = {
"action": "upload",
"stash": 1,
"filename": "chunk_test9.png",
"filesize": file_size,
"offset": 0,
"format": "json",
"token": CSRF_TOKEN,
"ignorewarnings": 1
}
file = {'chunk':('{}.jpg'.format(index),chunk,'multipart/form-data')}
index += 1
R = S.post(URL, files=file, data=PARAMS_4)
DATA = R.json()
print(DATA)
#For the second and further chunks, pass in the filekey parameter as well
for chunk in chunks:
PARAMS_4 = {
"action": "upload",
"stash": 1,
"offset": DATA["upload"]["offset"],
"filename": "chunk_test9.png",
"filesize": file_size,
"filekey": DATA["upload"]["filekey"],
"format": "json",
"token": CSRF_TOKEN,
}
file = {'chunk':('{}.jpg'.format(index),chunk,'multipart/form-data')}
index += 1
R = S.post(URL, files=file, data=PARAMS_4)
DATA = R.json()
print(DATA)