chenquincy / app-info-parser

A javascript parser for parsing .ipa or .apk files. IPA/APK文件 js 解析器
MIT License
492 stars 116 forks source link

Can't use in javascript with local file path! #83

Closed ArkarMM9599 closed 1 year ago

ArkarMM9599 commented 1 year ago

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!!!!

chenquincy commented 1 year ago

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.