mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.03k stars 796 forks source link

Error 404 WAPI.downloadFile function js #996

Closed Alezz1722 closed 3 years ago

Alezz1722 commented 3 years ago

I currently have the following codes to download multimedia files in js:

window.WAPI.downloadFile = function (msg, done) { let xhr = new XMLHttpRequest();

xhr.onload = function () {
    if (xhr.readyState == 4) {
        if (xhr.status == 200) {
            done(xhr.response, msg);
        } else {
            console.error(xhr.statusText);
        }
    } else {
        console.log(err);
        done(false);
    }
};

xhr.open("GET", msg.clientUrl, true);
xhr.responseType = 'arraybuffer';
//xhr.responseType = 'blob';
xhr.send(null);

};

function getMediaFile(msg, callbackFunction) { window.WAPI.downloadFile(msg, function(result, message) { Store.CryptoLib.decryptE2EMedia(message.type, result, message.mediaKey, message.mimetype).then(function(a) { const reader = new FileReader();

        reader.addEventListener('loadend', (e) => {
            callbackFunction(e.target);
        });

        reader.readAsDataURL(a._blob);
    });
});

}

When I try to download I get the following:

image

image

I don't know how to solve this problem, if you could help me or give me an idea of what to do, I would be very grateful.

g4w4 commented 3 years ago

do you have any idea how to solve it

erm3nda commented 3 years ago

There's no clientUrl anymore, now is something like deprecatedMms3Url. You have to modify your file objects/message.py

I did this and worked:

self.client_url = self._js_obj.get("clientUrl")
if not self.client_url:
    self.client_url = self._js_obj["deprecatedMms3Url"]