Giter Club home page Giter Club logo

Comments (5)

catosaurusrex2003 avatar catosaurusrex2003 commented on May 28, 2024

you are sending the blob correctly. you just have to convert it back to a blob while recieving.

conn.on('data', data => {
  console.log('listenConn data', data);
  if (data.evenBinary instanceof ArrayBuffer) {
    const blob = new Blob([data.evenBinary], { type: 'text/html' });
    // Now you have a Blob object
  }
});

check if this snippet works

from peerjs.

XhstormR avatar XhstormR commented on May 28, 2024

@catosaurusrex2003 This means peerjs will only transfer the bytes of the blob, but will ignore the type field, I need to handle the type field myself, right?

Background:This Blob object is a local file selected by the user, so I cannot sure the type of this file.

from peerjs.

catosaurusrex2003 avatar catosaurusrex2003 commented on May 28, 2024

my bad. i read your issue wrong. yes this is a bug i think.

from peerjs.

irgalamarr avatar irgalamarr commented on May 28, 2024

Hi @XhstormR,
the behavior you noticed is actually expected, but we see how our documentation might have confused you. We're sorry for that mix-up and we're working on making our docs better.

For now, we suggest looking at this example about transferring files with PeerJS. It should clear things up and show you how to handle the file transfer process. If you have more questions, just let us know; we're here to help.

from peerjs.

XhstormR avatar XhstormR commented on May 28, 2024

@irgalamarr Thanks. As shown in the example, I need to handle the type field myself.

https://github.com/chidokun/p2p-file-transfer/blob/main/src/App.tsx#L65

from peerjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.