WebWhatsapp-Wrapper icon indicating copy to clipboard operation
WebWhatsapp-Wrapper copied to clipboard

Download image problem

Open eduardobento opened this issue 5 years ago • 13 comments

I´m use msg.mediaData.attributes.renderableUrl to get blob url to download image. But now is undefined. Any ideias ?

eduardobento avatar Sep 27 '19 08:09 eduardobento

same problem here

mmoreirasouza avatar Sep 27 '19 12:09 mmoreirasouza

Help. model.mediaData.mediaBlob is null

fidelinkbr avatar Sep 27 '19 17:09 fidelinkbr

We have the same problem. We used to use message_js["mediaData"]["renderableUrl"] to retrieve the media but now, that attribute is "None"

janke184 avatar Sep 27 '19 20:09 janke184

I think it's an instability of WHATSAP, because the property sometimes appears and sometimes it disappears in my browser, when that happens, only the preview of the image works.

Em sex, 27 de set de 2019 às 17:46, Giancarlo [email protected] escreveu:

We have the same problem. We used to use message_js["mediaData"]["renderableUrl"] to retrieve the media but now, that attribute is "None"

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/718?email_source=notifications&email_token=AIDD5YOI6XAP5HW5HOY62Q3QLZWJTA5CNFSM4I3DHMG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD72BSIQ#issuecomment-536090914, or mute the thread https://github.com/notifications/unsubscribe-auth/AIDD5YL5WVGS747UE6XQLUTQLZWJTANCNFSM4I3DHMGQ .

--

Edison Figueira Junior 11 99308-6451

efjgrub avatar Sep 27 '19 20:09 efjgrub

for document, video and audio media type it works just for image it's undefined

mmoreirasouza avatar Sep 27 '19 21:09 mmoreirasouza

Any solution or walkthrough?

yurik44 avatar Sep 27 '19 22:09 yurik44

Anybody here had sucess ?

Em sex, 27 de set de 2019 19:58, yurik44 [email protected] escreveu:

Any solution or walkthrough?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/718?email_source=notifications&email_token=AIDD5YNXESIOM74Z7B6CH2LQL2FXTA5CNFSM4I3DHMG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD72I5VI#issuecomment-536121045, or mute the thread https://github.com/notifications/unsubscribe-auth/AIDD5YKUASKDMU6BKJVKFSDQL2FXTANCNFSM4I3DHMGQ .

efjgrub avatar Sep 28 '19 18:09 efjgrub

Anybody here had sucess ? Em sex, 27 de set de 2019 19:58, yurik44 [email protected] escreveu: Any solution or walkthrough? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#718?email_source=notifications&email_token=AIDD5YNXESIOM74Z7B6CH2LQL2FXTA5CNFSM4I3DHMG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD72I5VI#issuecomment-536121045>, or mute the thread https://github.com/notifications/unsubscribe-auth/AIDD5YKUASKDMU6BKJVKFSDQL2FXTANCNFSM4I3DHMGQ .

Not yet :(

I've noticed that there's a new way request when images are loaded

I got every parameters that the request require, but the request download a .enc file.

I'm tring to find the method thats create de blob' link but I'm not having luck with it and I'm not right that it is the correct way :(

samuelrbo avatar Sep 28 '19 21:09 samuelrbo

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);
    };

downloadFile(messageObj, function(result, message) { console.log("Encryption Key:" + message.mediaKey); console.log("Image Data:"); console.log(result); Store.CryptoLib.decryptE2EMedia(message.type, result, message.mediaKey, message.mimetype).then(function(a) { console.log("Decrypted Data:"); console.log(a); console.log(a._blob);

                                let reader = new FileReader();
                                reader.readAsDataURL(a._blob);
                                reader.onload = function (e) {
                                    console.log("FileReader result1:")
                                    console.log(reader.result)
                                    console.log("FileReader result2:")
                                    console.log(reader.result.substr(reader.result.indexOf(',') + 1));
                                };
                            }).catch(function(e) {
                                console.log("Error: " + e);
                            });
                        });

eduardobento avatar Sep 28 '19 22:09 eduardobento

Tnx @eduardobento

Just organizing a response from @eduardobento

  1. Change the downloadFIle méthod from WAPI to use msg object instead of url
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);
};
  1. Use the callback function and retrive the BLOB link.
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);
        });
    });
}

samuelrbo avatar Sep 29 '19 00:09 samuelrbo

It seems that this way, though, images are returned compressed and not in their original resolutions. Or am I missing something here?

fattynoparents avatar Oct 03 '19 10:10 fattynoparents

In python:

elif message.type == 'image' or message.type == 'video':
                print('-- Image or Video')
                print('filename', message.filename)
                print('size', message.size)
                print('mime', message.mime)
                print('caption', message.caption)
                print('client_url', message.client_url)
                message.save_media('./images',force_download=True)

jersonjunior avatar Oct 17 '19 12:10 jersonjunior