pyChomikBox
pyChomikBox copied to clipboard
Upload pause issue
I recive this error uploading small files, big files are ok. Windows, python 3.7.5 Credentials are ok, I just hide some sensitive informations. As I just said, I can upload big files.
[00:16:35][DEBUG]: urllib3.connectionpool | Starting new HTTPS connection (1): box.chomikuj.pl:443
[00:16:35][DEBUG]: urllib3.connectionpool | https://box.chomikuj.pl:443 "POST /services/ChomikBoxService.svc HTTP/1.1" 200 391
[00:16:35][DEBUG]: ChomikBox.Chomik.username | Action sent: "Auth"
[00:16:35][DEBUG]: ChomikBox.Chomik.username | Logged in with token <hidden>
[00:16:35][DEBUG]: urllib3.connectionpool | Starting new HTTPS connection (1): chomikuj.pl:443
[00:16:35][DEBUG]: urllib3.connectionpool | https://chomikuj.pl:443 "GET /chomik/chomikbox/LoginFromBox?t=<hidden>&returnUrl=username HTTP/1.1" 302 122
[00:16:36][DEBUG]: urllib3.connectionpool | https://chomikuj.pl:443 "GET /username HTTP/1.1" 200 16916
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Loading folders from folder 0
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Sending action: "Folders"
[00:16:36][DEBUG]: urllib3.connectionpool | https://box.chomikuj.pl:443 "POST /services/ChomikBoxService.svc HTTP/1.1" 200 None
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Action sent: "Folders"
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Getting file upload data for file "README.rst" in folder 461
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Sending action: "UploadToken"
[00:16:36][DEBUG]: urllib3.connectionpool | https://box.chomikuj.pl:443 "POST /services/ChomikBoxService.svc HTTP/1.1" 200 412
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Action sent: "UploadToken"
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Started uploading file "README.rst" to folder 461
[00:16:36][DEBUG]: urllib3.connectionpool | Starting new HTTP connection (1): s6963.chomikuj.pl:8084
869
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Upload of file "README.rst" paused
[00:16:37][DEBUG]: urllib3.connectionpool | Starting new HTTP connection (2): s6963.chomikuj.pl:8084
[00:16:37][DEBUG]: urllib3.connectionpool | http://s6963.chomikuj.pl:8084 "GET /resume/check/?key=<hidden> HTTP/1.1" 200 57
Traceback (most recent call last):
File "example.py", line 70, in <module>
uploader.resume()
File "C:\Users\kamil\Desktop\pyChomikBox-master\ChomikBox\ChomikBox.py", line 696, in resume
resume_from = int(resp['@file_size'])
KeyError: '@file_size'
What means "big" file and what means "small" file? Few kBs? MBs?
Small - 900B (README.rst from this project) Big - 150G img file I also try with 30M file, everything work nice, I also get one pause while uploading and it works ok.
Could you please test with other file sizes? Eg. A little bigger files?
Problem
Currently, first request sent by pyChomikBox always receives 400 error (it's badly formatted). Somehow for files bigger than 20-30kb pyChomikBox is able to get RESUME key. Then resume function works correctly (files is uploaded).
POST /file/ HTTP/1.1
Host: s8....chomikuj.pl:8084
User-Agent: Mozilla/5.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Type: multipart/form-data; boundary=acaa8d4c6e394b42a4b225923c984f64
Cookie: __cfduid=dae....
Content-Length: 1770
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Sun, 07 Mar 2021 14:25:32 GMT
Connection: close
Content-Length: 311
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request</h2>
<hr><p>HTTP Error 400. The request is badly formed.</p>
</BODY></HTML>
It looks like file upload is paused before it starts ;) Application then tries to get resume key, but "file is already uploaded" so no resume key is returned by chomikuj.pl
Chomikuj returns then response code -31 ( res="-31"
)
<Response [200]>
b'<?xml version="1.0" encoding="utf-8"?>\r\n<resp res="-31"/>'
Below is correct Resume response from Chomikuj when resume key is returned.
<Response [200]>
b'<?xml version="1.0" encoding="utf-8"?>\r\n<resp file_size="1483894784" skipThumbnails="true" res="1"/>'
Solutions:
- Switch entirely to Web Upload (I have already made changes on my fork https://github.com/felixd/pyChomikBox/tree/web_upload/ Upload is done over HTTPS :)
- Mix? For files smaller than in example 100kb use Web Upload, for files > use old solution
- Fix for current Upload function ;)
Logs
[11:30:23][DEBUG]: ChomikBox.Chomik.felixd | Sending web action: "Upload/GetUrl"
[11:30:24][DEBUG]: urllib3.connectionpool | https://chomikuj.pl:443 "POST /action/Upload/GetUrl HTTP/1.1" 200 None
[11:30:24][DEBUG]: ChomikBox.Chomik.felixd | Uploader.start()
[11:30:24][DEBUG]: ChomikBox.Chomik.felixd | Uploader.start(): Started uploading file "test-1kb" to folder 70
[11:30:24][DEBUG]: urllib3.connectionpool | Starting new HTTPS connection (1): s9537.chomikuj.pl:8885
1059
[11:30:24][DEBUG]: urllib3.connectionpool | https://s9537.chomikuj.pl:8885 "POST /upload?e=05Ibv[...]GA&pv=2 HTTP/1.1" 200 143
[11:30:24][DEBUG]: ChomikBox.Chomik.felixd | Uploader.start(): Upload of file "test-1kb" finished
1059
test-1kb [################################] 100.0% (1.03 KiB/1.03 KiB) 974.81 B/s
[11:30:25][DEBUG]: ChomikBox.Chomik.felixd | Sending action: "Logout"
[11:30:25][DEBUG]: urllib3.connectionpool | https://box.chomikuj.pl:443 "POST /services/ChomikBoxService.svc HTTP/1.1" 200 303
[11:30:25][DEBUG]: ChomikBox.Chomik.felixd | Action sent: "Logout"
[11:30:25][DEBUG]: ChomikBox.Chomik.felixd | Logged out