Skip to content
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

websocket文件分片上传支持并发分片上传吗? #14

Open
littleQing opened this issue Jun 23, 2021 · 0 comments
Open

websocket文件分片上传支持并发分片上传吗? #14

littleQing opened this issue Jun 23, 2021 · 0 comments

Comments

@littleQing
Copy link

// 构建Socket.IO Blob数据并请求,最后请求合并分片
async buildBlobData(chunkCount, file, hash, res) {
const that = this;
const blobData = [];
for (let i = 0; i < chunkCount; i++) {
if (
res.type == 0 ||
(res.type == 1 &&
res.index &&
res.index.length > 0 &&
!res.index.includes(i.toString()))
) {
const start = i * that.chunkSize;
const end = Math.min(file.size, start + that.chunkSize);
const blobItem = Object.create({});
blobItem.file = blobSlice.call(file, start, end);
blobItem.name = file.name;
blobItem.total = chunkCount;
blobItem.chunkSize = that.chunkSize;
blobItem.index = i;
blobItem.size = file.size;
blobItem.hash = hash;
blobData.push(blobItem);
}
}
for (let item of blobData) {
await that.socket.emit("upload", item);
}
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant