forked from inotia00/rvx-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuploadAPKFile.js
46 lines (39 loc) · 1.03 KB
/
uploadAPKFile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const AppInfoParser = require('app-info-parser');
const { renameSync } = require('node:fs');
function uploadAPKFile(req, res, ws) {
const file = req.files.apk;
file.mv('./revanced/temp.apk', async (err) => {
if (err) {
for (const websocket of ws) {
websocket.send(
JSON.stringify({
event: 'error',
error: err
})
);
}
}
const app = new AppInfoParser('./revanced/temp.apk');
const resp = await app.parse();
const { package, versionName, icon } = resp;
const appName = resp.application.label[0];
await renameSync('./revanced/temp.apk', `./revanced/${package}.apk`);
global.jarNames.selectedApp = {
packageName: package,
uploaded: true
};
for (const websocket of ws) {
websocket.send(
JSON.stringify({
event: 'apkUploaded',
package,
versionName,
appName,
icon
})
);
}
});
return res.sendStatus(204);
}
module.exports = uploadAPKFile;