(url, form, needBinary)
| 1597 | } |
| 1598 | |
| 1599 | function postHuaweiForm (url, form, needBinary) { |
| 1600 | return new Promise((accept, reject) => { |
| 1601 | const parsed = new URL(url); |
| 1602 | const protocol = (parsed.protocol === 'https:' ? https : http); |
| 1603 | const options = { |
| 1604 | host: parsed.host, |
| 1605 | path: parsed.pathname + parsed.search, |
| 1606 | method: 'POST', |
| 1607 | headers: Object.assign(form.getHeaders(), { |
| 1608 | 'accept': 'application/json', |
| 1609 | 'User-Agent': 'Telegram-X-Publisher' |
| 1610 | }) |
| 1611 | }; |
| 1612 | const req = protocol.request(options, (res) => { |
| 1613 | toUtf8(res, (contentType, content) => { |
| 1614 | accept({statusCode: res.statusCode, statusMessage: res.statusMessage, content, contentType}); |
| 1615 | }, needBinary); |
| 1616 | }).on('error', reject); |
| 1617 | form.pipe(req); |
| 1618 | }); |
| 1619 | } |
| 1620 | |
| 1621 | async function uploadHuaweiApk (build, targetFiles, accessToken, uploadUrl, authCode) { |
| 1622 | const apkFilePath = targetFiles.apkFile.path; |
no test coverage detected