def rapid_upload(cookie, tokens, source_path, path, upload_mode):
ondup = const.UPLOAD_ONDUP[upload_mode]<EOL>content_length = os.path.getsize(source_path)<EOL>assert content_length > RAPIDUPLOAD_THRESHOLD, '<STR_LIT>'<EOL>dir_name, file_name = os.path.split(path)<EOL>content_md5 = hasher.md5(source_path)<EOL>slice_md5 = hasher.md5(source_path, <NUM_LIT:0>, RAPIDUPLOAD_THRESHOLD)<EOL>url = '<STR_LIT>'.join([<EOL>const.PCS_URL_C,<EOL>'<STR_LIT>',<EOL>'<STR_LIT>', ondup,<EOL>'<STR_LIT>', encoder.encode_uri_component(dir_name),<EOL>'<STR_LIT>', encoder.encode_uri_component(file_name),<EOL>'<STR_LIT>', str(content_length),<EOL>'<STR_LIT>', content_md5,<EOL>'<STR_LIT>', slice_md5,<EOL>'<STR_LIT>', encoder.encode_uri_component(path),<EOL>'<STR_LIT:&>', cookie.sub_output('<STR_LIT>'),<EOL>'<STR_LIT>', tokens['<STR_LIT>'],<EOL>])<EOL>req = net.urlopen(url, headers={'<STR_LIT>': cookie.header_output()})<EOL>if req:<EOL><INDENT>return json.loads(req.data.decode())<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
快速上传