获得徽章 0
const readSteam = fse.createReadStream(readP)
const weiteSteam = fse.createWriteStream(filePath,{start:size*i,end:(i+1)*size})
readSteam.pipe(weiteSteam)
readSteam.on('end',async ()=>{
fse.unlinkSync(readP)
resolve()
})
这段代码包含在一个promise里,在前端通过分片传过来后,我通过这种方法并发合并后图片有时候可以打开,有时候打不开,已知应该是合并的流排错了,在这之前也排过序了但是没有效果,现在还有什么其他办法
const weiteSteam = fse.createWriteStream(filePath,{start:size*i,end:(i+1)*size})
readSteam.pipe(weiteSteam)
readSteam.on('end',async ()=>{
fse.unlinkSync(readP)
resolve()
})
这段代码包含在一个promise里,在前端通过分片传过来后,我通过这种方法并发合并后图片有时候可以打开,有时候打不开,已知应该是合并的流排错了,在这之前也排过序了但是没有效果,现在还有什么其他办法
展开
评论
点赞
使用video全屏有什么办法可以自定义控件吗?我现在使用的是div全屏,但是div里面的视频在放大后是否会造成视频模糊?我不知道是不是视频的原因在放大后有轻微的模糊。
3
1
#新人报道# 在进行微信小程序多文件上传时,发现有个函数unicode码转utf-8的编码函数,这个是什么原理?看不懂啊
String.prototype.utf8CodeAt = function(i) {
var str = this;
var out = [], p = 0;
var c = str.charCodeAt(i);
if (c < 128) {
out[p++] = c;
} else if (c < 2048) {
out[p++] = (c >> 6) | 192;
out[p++] = (c & 63) | 128;
} else if (
((c & 0xFC00) == 0xD800) && (i + 1) < str.length &&
((str.charCodeAt(i + 1) & 0xFC00) == 0xDC00)) {
// Surrogate Pair
c = 0x10000 + ((c & 0x03FF) << 10) + (str.charCodeAt(++i) & 0x03FF);
out[p++] = (c >> 18) | 240;
out[p++] = ((c >> 12) & 63) | 128;
out[p++] = ((c >> 6) & 63) | 128;
out[p++] = (c & 63) | 128;
} else {
out[p++] = (c >> 12) | 224;
out[p++] = ((c >> 6) & 63) | 128;
out[p++] = (c & 63) | 128;
}
return out;
};
String.prototype.utf8CodeAt = function(i) {
var str = this;
var out = [], p = 0;
var c = str.charCodeAt(i);
if (c < 128) {
out[p++] = c;
} else if (c < 2048) {
out[p++] = (c >> 6) | 192;
out[p++] = (c & 63) | 128;
} else if (
((c & 0xFC00) == 0xD800) && (i + 1) < str.length &&
((str.charCodeAt(i + 1) & 0xFC00) == 0xDC00)) {
// Surrogate Pair
c = 0x10000 + ((c & 0x03FF) << 10) + (str.charCodeAt(++i) & 0x03FF);
out[p++] = (c >> 18) | 240;
out[p++] = ((c >> 12) & 63) | 128;
out[p++] = ((c >> 6) & 63) | 128;
out[p++] = (c & 63) | 128;
} else {
out[p++] = (c >> 12) | 224;
out[p++] = ((c >> 6) & 63) | 128;
out[p++] = (c & 63) | 128;
}
return out;
};
展开
3
2
![[流泪]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_6.dde0d83.png)