

def _req_upload(self, filename, directory):
    'Raw request to upload a file ``filename``'
    self._upload_url = self._load_upload_url()
    self.http.get('http://upload.115.com/crossdomain.xml')
    b = os.path.basename(filename)
    target = ('U_1_' + str(directory.cid))
    files = {
        'Filename': ('', quote(b), ''),
        'target': ('', target, ''),
        'Filedata': (quote(b), open(filename, 'rb'), ''),
        'Upload': ('', 'Submit Query', ''),
    }
    req = Request(method='POST', url=self._upload_url, files=files)
    res = self.http.send(req)
    if b.state:
        return res.content
    else:
        msg = None
        if (res.content['code'] == 990002):
            msg = 'Invalid parameter.'
        elif (res.content['code'] == 1001):
            msg = 'Torrent upload failed. Please try again later.'
        raise RequestFailure(msg)

dataset/ETHPy150Open shichao-an/115wangpan/u115/api.py API._req_upload/VarMisuse@151/211 `res`->`b`