javascript - Get file type after sending the file from WebRTC -


i using webrtc 2 clients communicated using peer.js

var peer = new peer( {     key: "xxx",     config: {"xxx": [{ url: "xxxxxxx" }]} }); 

my main aim send file 1 client another. using following code:

$("#box").on("drop", function(e) {     e.originalevent.preventdefault();     var file = e.originalevent.datatransfer.files[0];     console.log(file);     connection.send(file); }); 

on receiving end using below code:

conn.on("data", function(data) {     if (data.constructor === arraybuffer)     {         var dataview = new uint8array(data);         var datablob = new blob([dataview]);         var reader = new window.filereader();         reader.readastext(datablob);           console.log(reader);     } } 

now problem want file type can save in proper format. using download.js save file.

it not possible type raw data except there file type/hint embedded in data (e.g. zip, pdf). should create own protocol send filename well.

what did use channel's protocol property set filename extension transfer these type of metadata information.

note few weeks ago sending blobs wasn't supported in chrome (at least in 1 of example applications).


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -