Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6962f52

Browse files
authored
Read files in chunks for sendFile (#1475)
1 parent c0c5642 commit 6962f52

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/room/participant/LocalParticipant.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,7 @@ export default class LocalParticipant extends Participant {
15651565
destinationIdentities: options?.destinationIdentities,
15661566
topic: options?.topic,
15671567
attachedStreamIds: fileIds,
1568+
attributes: options?.attributes,
15681569
});
15691570

15701571
await writer.write(text);
@@ -1602,13 +1603,15 @@ export default class LocalParticipant extends Participant {
16021603
timestamp: Date.now(),
16031604
topic: options?.topic ?? '',
16041605
size: options?.totalSize,
1606+
attributes: options?.attributes,
16051607
};
16061608
const header = new DataStream_Header({
16071609
streamId,
16081610
mimeType: info.mimeType,
16091611
topic: info.topic,
16101612
timestamp: numberToBigInt(info.timestamp),
16111613
totalLength: numberToBigInt(options?.totalSize),
1614+
attributes: info.attributes,
16121615
contentHeader: {
16131616
case: 'textHeader',
16141617
value: new DataStream_TextHeader({
@@ -1722,8 +1725,14 @@ export default class LocalParticipant extends Participant {
17221725
topic: options?.topic,
17231726
destinationIdentities: options?.destinationIdentities,
17241727
});
1725-
1726-
await writer.write(new Uint8Array(await file.arrayBuffer()));
1728+
const reader = file.stream().getReader();
1729+
while (true) {
1730+
const { done, value } = await reader.read();
1731+
if (done) {
1732+
break;
1733+
}
1734+
await writer.write(value);
1735+
}
17271736
await writer.close();
17281737
return writer.info;
17291738
}

vite.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export default defineConfig({
1010
server: {
1111
port: 8080,
1212
open: true,
13+
fs: {
14+
strict: false,
15+
},
1316
},
1417
build: {
1518
minify: 'esbuild',

0 commit comments

Comments
 (0)