-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't send Blob object #1254
Comments
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 |
@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. |
my bad. i read your issue wrong. yes this is a bug i think. |
Hi @XhstormR, 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. |
@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 |
Please, check for existing issues to avoid duplicates.
What happened?
According to the documentation, sending Blob objects is supported.
But when I send a object that containing the Blob, on the other side it becomes an ArrayBuffer.
Corresponding code:
other side:
How can we reproduce the issue?
No response
What do you expected to happen?
Able to successfully send Blob object.
Environment setup
Is this a regression?
peerjs 1.5.2, angular 17.3.0, Google Chrome 123.0.6312.59
Anything else?
No response
The text was updated successfully, but these errors were encountered: