app-info-parser
app-info-parser copied to clipboard
Can't use in javascript with local file path!
I'm trying to parse apk data from local path apk like "D:/apk/Telegram.apk" but still occurs many errors.
const parser = new AppInfoParser('D:/apk/Telegram.apk')
This line give this error => "Param error: [file] must be an instance of Blob or File in browser."
So i try with this function to create file object from local file path.
**const process_apk_file = async (file_path) => { const response = await fetch(file_path); const blob = await response.blob();
const processed_apk = new File([blob], 'telegram.apk', {type: "application/vnd.android.package-archive"}); return processed_apk }**
process_apk_file(FileURL).then(f => { const parser = new AppInfoParser(f) // or xxx.ipa parser.parse().then(result => { console.log('app info ----> ', result) console.log('icon base64 ----> ', result.icon) }).catch(err => { console.log('err ----> ', err) }) })
And new error => TypeError: The "path" argument must be of type string or an instance of Buffer or URL. Received an instance of File
Help Me!!!!
D:/apk/Telegram.apk
is a file path that only can be use in Node env. If you use it in browser, you should use an input element to get the file blob. Here is a sample demo.