w-converhp 2.0.29 → 2.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/w-converhp-client.umd.js +2 -2
- package/dist/w-converhp-client.umd.js.map +1 -1
- package/dist/w-converhp-server.umd.js +2 -2
- package/dist/w-converhp-server.umd.js.map +1 -1
- package/docs/WConverhpClient.html +2 -2
- package/docs/WConverhpClient.mjs.html +27 -40
- package/docs/WConverhpServer.html +2 -2
- package/docs/WConverhpServer.mjs.html +40 -15
- package/docs/index.html +1 -1
- package/package.json +2 -2
- package/sclc.mjs +2 -2
- package/src/WConverhpClient.mjs +26 -39
- package/src/WConverhpServer.mjs +39 -14
- package/src/mergeFiles.wk.umd.js +1 -1
- package/srv.mjs +1 -1
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
|
|
81
81
|
<dt class="tag-source">Source:</dt>
|
|
82
82
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
83
|
-
<a href="WConverhpServer.mjs.html">WConverhpServer.mjs</a>, <a href="WConverhpServer.mjs.html#
|
|
83
|
+
<a href="WConverhpServer.mjs.html">WConverhpServer.mjs</a>, <a href="WConverhpServer.mjs.html#line192">line 192</a>
|
|
84
84
|
</li></ul></dd>
|
|
85
85
|
|
|
86
86
|
|
|
@@ -749,7 +749,7 @@
|
|
|
749
749
|
<br class="clear">
|
|
750
750
|
|
|
751
751
|
<footer>
|
|
752
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
752
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat Apr 12 2025 22:14:41 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
753
753
|
</footer>
|
|
754
754
|
|
|
755
755
|
<script>prettyPrint();</script>
|
|
@@ -60,6 +60,7 @@ import isp0int from 'wsemi/src/isp0int.mjs'
|
|
|
60
60
|
import ispint from 'wsemi/src/ispint.mjs'
|
|
61
61
|
import isearr from 'wsemi/src/isearr.mjs'
|
|
62
62
|
import isbol from 'wsemi/src/isbol.mjs'
|
|
63
|
+
import isnum from 'wsemi/src/isnum.mjs'
|
|
63
64
|
import isfun from 'wsemi/src/isfun.mjs'
|
|
64
65
|
import ispm from 'wsemi/src/ispm.mjs'
|
|
65
66
|
import cint from 'wsemi/src/cint.mjs'
|
|
@@ -71,7 +72,7 @@ import u8arr2obj from 'wsemi/src/u8arr2obj.mjs'
|
|
|
71
72
|
import fsIsFile from 'wsemi/src/fsIsFile.mjs'
|
|
72
73
|
import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
|
|
73
74
|
import fsCreateFolder from 'wsemi/src/fsCreateFolder.mjs'
|
|
74
|
-
import
|
|
75
|
+
import fsGetFileXxHash from 'wsemi/src/fsGetFileXxHash.mjs'
|
|
75
76
|
import mergeFiles from './mergeFiles.wk.umd.js'
|
|
76
77
|
// import mergeFiles from './mergeFiles.mjs'
|
|
77
78
|
|
|
@@ -647,9 +648,9 @@ function WConverhpServer(opt = {}) {
|
|
|
647
648
|
},
|
|
648
649
|
}
|
|
649
650
|
|
|
650
|
-
//
|
|
651
|
-
let
|
|
652
|
-
path: `/${apiName}
|
|
651
|
+
//apiUploadCheck
|
|
652
|
+
let apiUploadCheck = {
|
|
653
|
+
path: `/${apiName}ulck`,
|
|
653
654
|
method: 'POST',
|
|
654
655
|
options: {
|
|
655
656
|
payload: {
|
|
@@ -686,7 +687,7 @@ function WConverhpServer(opt = {}) {
|
|
|
686
687
|
if (true) {
|
|
687
688
|
|
|
688
689
|
//verifyConn
|
|
689
|
-
let m = verifyConn({ apiType: 'upload-check
|
|
690
|
+
let m = verifyConn({ apiType: 'upload-check', authorization, headers, query })
|
|
690
691
|
if (ispm(m)) {
|
|
691
692
|
m = await m
|
|
692
693
|
}
|
|
@@ -700,15 +701,17 @@ function WConverhpServer(opt = {}) {
|
|
|
700
701
|
|
|
701
702
|
//eeEmit
|
|
702
703
|
eeEmit('handler', {
|
|
703
|
-
api: '
|
|
704
|
+
api: 'apiUploadCheck',
|
|
704
705
|
headers,
|
|
705
706
|
query,
|
|
706
707
|
})
|
|
707
708
|
|
|
708
|
-
//filename, fileHash, 從payload接收
|
|
709
|
+
//filename, fileSize, fileHash, 從payload接收
|
|
709
710
|
let filename = get(req, 'payload.filename', '')
|
|
711
|
+
let fileSize = get(req, 'payload.fileSize', '')
|
|
710
712
|
let fileHash = get(req, 'payload.fileHash', '')
|
|
711
713
|
// console.log('filename', filename)
|
|
714
|
+
// console.log('fileSize', fileSize)
|
|
712
715
|
// console.log('fileHash', fileHash)
|
|
713
716
|
|
|
714
717
|
//check
|
|
@@ -717,6 +720,12 @@ function WConverhpServer(opt = {}) {
|
|
|
717
720
|
return responseU8aStreamWithError(res, 'invalid filename in payload')
|
|
718
721
|
}
|
|
719
722
|
|
|
723
|
+
//check
|
|
724
|
+
if (!isnum(fileSize)) {
|
|
725
|
+
// console.log('invalid fileSize in payload')
|
|
726
|
+
return responseU8aStreamWithError(res, 'invalid fileSize in payload')
|
|
727
|
+
}
|
|
728
|
+
|
|
720
729
|
//check
|
|
721
730
|
if (!isestr(fileHash)) {
|
|
722
731
|
// console.log('invalid fileHash in payload')
|
|
@@ -739,19 +748,35 @@ function WConverhpServer(opt = {}) {
|
|
|
739
748
|
return responseU8aStream(res, u8aOut, { returnType: 'success', returnMsg: 'need to parse' })
|
|
740
749
|
}
|
|
741
750
|
|
|
742
|
-
//
|
|
743
|
-
let
|
|
751
|
+
//_fileSize
|
|
752
|
+
let stats = fs.statSync(pathFile)
|
|
753
|
+
let _fileSize = stats.size
|
|
754
|
+
|
|
755
|
+
//check
|
|
756
|
+
if (fileSize !== _fileSize) {
|
|
757
|
+
let out = {
|
|
758
|
+
success: {
|
|
759
|
+
existed: false,
|
|
760
|
+
msg: 'not equal size',
|
|
761
|
+
},
|
|
762
|
+
}
|
|
763
|
+
let u8aOut = obj2u8arr(out)
|
|
764
|
+
return responseU8aStream(res, u8aOut, { returnType: 'success', returnMsg: 'need to parse' })
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
//_fileHash
|
|
768
|
+
let _fileHash = await fsGetFileXxHash(pathFile)
|
|
744
769
|
// console.log('path', pathFile)
|
|
745
770
|
// console.log('hash(front)', fileHash)
|
|
746
|
-
// console.log('hash(backend)',
|
|
771
|
+
// console.log('hash(backend)', _fileHash)
|
|
747
772
|
// console.log('')
|
|
748
773
|
|
|
749
774
|
//check
|
|
750
|
-
if (fileHash !==
|
|
775
|
+
if (fileHash !== _fileHash) {
|
|
751
776
|
let out = {
|
|
752
777
|
success: {
|
|
753
778
|
existed: false,
|
|
754
|
-
msg: 'not equal',
|
|
779
|
+
msg: 'not equal hash',
|
|
755
780
|
},
|
|
756
781
|
}
|
|
757
782
|
let u8aOut = obj2u8arr(out)
|
|
@@ -1453,7 +1478,7 @@ function WConverhpServer(opt = {}) {
|
|
|
1453
1478
|
apiRoutes = [
|
|
1454
1479
|
...apiRoutes,
|
|
1455
1480
|
apiMain,
|
|
1456
|
-
|
|
1481
|
+
apiUploadCheck,
|
|
1457
1482
|
apiUploadSlice,
|
|
1458
1483
|
apiUploadSliceMerge,
|
|
1459
1484
|
apiDownloadGetFilename,
|
|
@@ -1474,7 +1499,7 @@ function WConverhpServer(opt = {}) {
|
|
|
1474
1499
|
|
|
1475
1500
|
//start
|
|
1476
1501
|
if (get(opt, 'serverHapi')) {
|
|
1477
|
-
server.route([apiMain,
|
|
1502
|
+
server.route([apiMain, apiUploadCheck, apiUploadSlice, apiUploadSliceMerge, apiDownloadGetFilename, apiDownloadGetFile, apiDownload])
|
|
1478
1503
|
}
|
|
1479
1504
|
else {
|
|
1480
1505
|
startServer()
|
|
@@ -1507,7 +1532,7 @@ export default WConverhpServer
|
|
|
1507
1532
|
<br class="clear">
|
|
1508
1533
|
|
|
1509
1534
|
<footer>
|
|
1510
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
1535
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat Apr 12 2025 22:14:41 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1511
1536
|
</footer>
|
|
1512
1537
|
|
|
1513
1538
|
<script>prettyPrint();</script>
|
package/docs/index.html
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
<br class="clear">
|
|
72
72
|
|
|
73
73
|
<footer>
|
|
74
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
74
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat Apr 12 2025 22:14:41 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
75
75
|
</footer>
|
|
76
76
|
|
|
77
77
|
<script>prettyPrint();</script>
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-converhp",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.31",
|
|
4
4
|
"main": "dist/w-converhp-server.umd.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/hapi": "^21.4.0",
|
|
7
7
|
"@hapi/inert": "^7.1.0",
|
|
8
8
|
"axios": "^1.8.4",
|
|
9
9
|
"lodash-es": "^4.17.21",
|
|
10
|
-
"wsemi": "^1.7.
|
|
10
|
+
"wsemi": "^1.7.87"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"form-data": "^4.0.2",
|
package/sclc.mjs
CHANGED
|
@@ -27,10 +27,10 @@ wo.on('error', (err) => {
|
|
|
27
27
|
function uploadLargeFile() {
|
|
28
28
|
let core = async() => {
|
|
29
29
|
|
|
30
|
-
let fsz = '
|
|
30
|
+
let fsz = '1000mb' //0mb 10mb 100mb 1000mb
|
|
31
31
|
|
|
32
32
|
//u8a
|
|
33
|
-
let u8a =
|
|
33
|
+
let u8a = fs.readFileSync(`../_data/${fsz}.7z`) //用fs讀有檔案大小上限
|
|
34
34
|
console.log('u8a.length', u8a.length)
|
|
35
35
|
// console.log('uploadLargeFile u8a', u8a)
|
|
36
36
|
ms.push({ 'upload u8a.length': u8a.length })
|
package/src/WConverhpClient.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import axios from 'axios'
|
|
2
2
|
import get from 'lodash-es/get.js'
|
|
3
3
|
import isWindow from 'wsemi/src/isWindow.mjs'
|
|
4
|
-
import getGlobal from 'wsemi/src/getGlobal.mjs'
|
|
5
4
|
import evem from 'wsemi/src/evem.mjs'
|
|
6
5
|
import genPm from 'wsemi/src/genPm.mjs'
|
|
7
6
|
import haskey from 'wsemi/src/haskey.mjs'
|
|
@@ -19,7 +18,7 @@ import blob2u8arr from 'wsemi/src/blob2u8arr.mjs'
|
|
|
19
18
|
import obj2u8arr from 'wsemi/src/obj2u8arr.mjs'
|
|
20
19
|
import u8arr2obj from 'wsemi/src/u8arr2obj.mjs'
|
|
21
20
|
import pmConvertResolve from 'wsemi/src/pmConvertResolve.mjs'
|
|
22
|
-
|
|
21
|
+
import getFileXxHash from 'wsemi/src/getFileXxHash.mjs'
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
/**
|
|
@@ -165,8 +164,8 @@ function WConverhpClient(opt) {
|
|
|
165
164
|
else if (type === 'slice') {
|
|
166
165
|
urlUse = `${url}slc`
|
|
167
166
|
}
|
|
168
|
-
else if (type === 'upload-check
|
|
169
|
-
urlUse = `${url}
|
|
167
|
+
else if (type === 'upload-check') {
|
|
168
|
+
urlUse = `${url}ulck`
|
|
170
169
|
}
|
|
171
170
|
else if (type === 'slice-merge') {
|
|
172
171
|
urlUse = `${url}slcm`
|
|
@@ -628,37 +627,21 @@ function WConverhpClient(opt) {
|
|
|
628
627
|
|
|
629
628
|
//calcHash
|
|
630
629
|
async function calcHash(inp) {
|
|
631
|
-
let pm = genPm()
|
|
632
|
-
if (env === 'browser') {
|
|
633
|
-
//於browser時, 因是給予blob或file上傳, 且使用非同步async版計算hash, 可支援大檔
|
|
634
|
-
|
|
635
|
-
//crypto, 須通過global取得crypto, 否則會被舊版webpack偵測報錯
|
|
636
|
-
let g = getGlobal()
|
|
637
|
-
let crypto = get(g, 'crypto')
|
|
638
630
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
let hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
|
644
|
-
|
|
645
|
-
pm.resolve(hashHex)
|
|
631
|
+
//bb
|
|
632
|
+
let bb = null
|
|
633
|
+
if (env === 'browser') {
|
|
634
|
+
bb = inp
|
|
646
635
|
}
|
|
647
636
|
else {
|
|
648
|
-
//於nodejs時, 因尚無法提供檔名上傳, 故會是readFileSync讀入的buffer,
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
let key = 'crypto'
|
|
652
|
-
let crypto = await import(key)
|
|
637
|
+
//於nodejs時, 因尚無法提供檔名上傳, 故會是readFileSync讀入的buffer, 再轉成new Blob([buffer]), 供getFileXxHash使用
|
|
638
|
+
bb = new Blob([inp])
|
|
639
|
+
}
|
|
653
640
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
hash.update(inp, 'utf8')
|
|
657
|
-
let hashHex = hash.digest('hex')
|
|
641
|
+
//hash
|
|
642
|
+
let hash = await getFileXxHash(bb)
|
|
658
643
|
|
|
659
|
-
|
|
660
|
-
}
|
|
661
|
-
return pm
|
|
644
|
+
return hash
|
|
662
645
|
}
|
|
663
646
|
|
|
664
647
|
//sendDataSlice
|
|
@@ -675,7 +658,7 @@ function WConverhpClient(opt) {
|
|
|
675
658
|
}
|
|
676
659
|
if (n === 0) {
|
|
677
660
|
try {
|
|
678
|
-
n = bb.length //for
|
|
661
|
+
n = bb.length //for ArrayBuffer //nodejs用fs讀有檔案大小上限, 除非改傳入檔名用stream讀, 否則無法支援超大檔
|
|
679
662
|
n = cint(n)
|
|
680
663
|
}
|
|
681
664
|
catch (err) {}
|
|
@@ -687,27 +670,30 @@ function WConverhpClient(opt) {
|
|
|
687
670
|
}
|
|
688
671
|
// console.log('n', n)
|
|
689
672
|
|
|
690
|
-
//
|
|
673
|
+
//fileTotalSize
|
|
674
|
+
let fileTotalSize = n
|
|
675
|
+
|
|
676
|
+
//fileTotalHash
|
|
691
677
|
let fileTotalHash = await calcHash(bb)
|
|
692
678
|
// console.log('fileTotalHash', fileTotalHash)
|
|
693
679
|
|
|
694
680
|
//ckh
|
|
695
|
-
let ckh = async({ filename, fileHash }) => {
|
|
681
|
+
let ckh = async({ filename, fileSize, fileHash }) => {
|
|
696
682
|
|
|
697
|
-
//send upload-check
|
|
698
|
-
let resCk = await send('upload-check
|
|
683
|
+
//send upload-check
|
|
684
|
+
let resCk = await send('upload-check', { filename, fileSize, fileHash }, { dataType: 'json' })
|
|
699
685
|
// console.log('resCk', resCk)
|
|
700
686
|
|
|
701
687
|
return resCk
|
|
702
688
|
}
|
|
703
689
|
|
|
704
690
|
//rAll
|
|
705
|
-
let rAll = await ckh({ filename: fileTotalHash, fileHash: fileTotalHash })
|
|
691
|
+
let rAll = await ckh({ filename: fileTotalHash, fileSize: fileTotalSize, fileHash: fileTotalHash })
|
|
706
692
|
// console.log('rAll', rAll)
|
|
707
693
|
|
|
708
694
|
//check
|
|
709
695
|
if (rAll.existed) {
|
|
710
|
-
|
|
696
|
+
// console.log('已有上傳大檔')
|
|
711
697
|
let resMg = {
|
|
712
698
|
filename: fileTotalName,
|
|
713
699
|
path: rAll.path,
|
|
@@ -771,7 +757,7 @@ function WConverhpClient(opt) {
|
|
|
771
757
|
// console.log('fileSliceHash', fileSliceHash)
|
|
772
758
|
|
|
773
759
|
//rChunk
|
|
774
|
-
let rChunk = await ckh({ filename: fileSliceName, fileHash: fileSliceHash })
|
|
760
|
+
let rChunk = await ckh({ filename: fileSliceName, fileSize: sizeSlice, fileHash: fileSliceHash })
|
|
775
761
|
// console.log('fileSliceName', fileSliceName)
|
|
776
762
|
// console.log('fileSliceHash', fileSliceHash)
|
|
777
763
|
// console.log('rChunk', rChunk)
|
|
@@ -779,7 +765,8 @@ function WConverhpClient(opt) {
|
|
|
779
765
|
|
|
780
766
|
//check
|
|
781
767
|
if (rChunk.existed) {
|
|
782
|
-
|
|
768
|
+
// console.log('已有上傳切片檔')
|
|
769
|
+
cbProgressSlice({ prog: 100, m: 'upload' }) //直接觸發更新進度
|
|
783
770
|
continue
|
|
784
771
|
}
|
|
785
772
|
|
package/src/WConverhpServer.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import isp0int from 'wsemi/src/isp0int.mjs'
|
|
|
13
13
|
import ispint from 'wsemi/src/ispint.mjs'
|
|
14
14
|
import isearr from 'wsemi/src/isearr.mjs'
|
|
15
15
|
import isbol from 'wsemi/src/isbol.mjs'
|
|
16
|
+
import isnum from 'wsemi/src/isnum.mjs'
|
|
16
17
|
import isfun from 'wsemi/src/isfun.mjs'
|
|
17
18
|
import ispm from 'wsemi/src/ispm.mjs'
|
|
18
19
|
import cint from 'wsemi/src/cint.mjs'
|
|
@@ -24,7 +25,7 @@ import u8arr2obj from 'wsemi/src/u8arr2obj.mjs'
|
|
|
24
25
|
import fsIsFile from 'wsemi/src/fsIsFile.mjs'
|
|
25
26
|
import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
|
|
26
27
|
import fsCreateFolder from 'wsemi/src/fsCreateFolder.mjs'
|
|
27
|
-
import
|
|
28
|
+
import fsGetFileXxHash from 'wsemi/src/fsGetFileXxHash.mjs'
|
|
28
29
|
import mergeFiles from './mergeFiles.wk.umd.js'
|
|
29
30
|
// import mergeFiles from './mergeFiles.mjs'
|
|
30
31
|
|
|
@@ -600,9 +601,9 @@ function WConverhpServer(opt = {}) {
|
|
|
600
601
|
},
|
|
601
602
|
}
|
|
602
603
|
|
|
603
|
-
//
|
|
604
|
-
let
|
|
605
|
-
path: `/${apiName}
|
|
604
|
+
//apiUploadCheck
|
|
605
|
+
let apiUploadCheck = {
|
|
606
|
+
path: `/${apiName}ulck`,
|
|
606
607
|
method: 'POST',
|
|
607
608
|
options: {
|
|
608
609
|
payload: {
|
|
@@ -639,7 +640,7 @@ function WConverhpServer(opt = {}) {
|
|
|
639
640
|
if (true) {
|
|
640
641
|
|
|
641
642
|
//verifyConn
|
|
642
|
-
let m = verifyConn({ apiType: 'upload-check
|
|
643
|
+
let m = verifyConn({ apiType: 'upload-check', authorization, headers, query })
|
|
643
644
|
if (ispm(m)) {
|
|
644
645
|
m = await m
|
|
645
646
|
}
|
|
@@ -653,15 +654,17 @@ function WConverhpServer(opt = {}) {
|
|
|
653
654
|
|
|
654
655
|
//eeEmit
|
|
655
656
|
eeEmit('handler', {
|
|
656
|
-
api: '
|
|
657
|
+
api: 'apiUploadCheck',
|
|
657
658
|
headers,
|
|
658
659
|
query,
|
|
659
660
|
})
|
|
660
661
|
|
|
661
|
-
//filename, fileHash, 從payload接收
|
|
662
|
+
//filename, fileSize, fileHash, 從payload接收
|
|
662
663
|
let filename = get(req, 'payload.filename', '')
|
|
664
|
+
let fileSize = get(req, 'payload.fileSize', '')
|
|
663
665
|
let fileHash = get(req, 'payload.fileHash', '')
|
|
664
666
|
// console.log('filename', filename)
|
|
667
|
+
// console.log('fileSize', fileSize)
|
|
665
668
|
// console.log('fileHash', fileHash)
|
|
666
669
|
|
|
667
670
|
//check
|
|
@@ -670,6 +673,12 @@ function WConverhpServer(opt = {}) {
|
|
|
670
673
|
return responseU8aStreamWithError(res, 'invalid filename in payload')
|
|
671
674
|
}
|
|
672
675
|
|
|
676
|
+
//check
|
|
677
|
+
if (!isnum(fileSize)) {
|
|
678
|
+
// console.log('invalid fileSize in payload')
|
|
679
|
+
return responseU8aStreamWithError(res, 'invalid fileSize in payload')
|
|
680
|
+
}
|
|
681
|
+
|
|
673
682
|
//check
|
|
674
683
|
if (!isestr(fileHash)) {
|
|
675
684
|
// console.log('invalid fileHash in payload')
|
|
@@ -692,19 +701,35 @@ function WConverhpServer(opt = {}) {
|
|
|
692
701
|
return responseU8aStream(res, u8aOut, { returnType: 'success', returnMsg: 'need to parse' })
|
|
693
702
|
}
|
|
694
703
|
|
|
695
|
-
//
|
|
696
|
-
let
|
|
704
|
+
//_fileSize
|
|
705
|
+
let stats = fs.statSync(pathFile)
|
|
706
|
+
let _fileSize = stats.size
|
|
707
|
+
|
|
708
|
+
//check
|
|
709
|
+
if (fileSize !== _fileSize) {
|
|
710
|
+
let out = {
|
|
711
|
+
success: {
|
|
712
|
+
existed: false,
|
|
713
|
+
msg: 'not equal size',
|
|
714
|
+
},
|
|
715
|
+
}
|
|
716
|
+
let u8aOut = obj2u8arr(out)
|
|
717
|
+
return responseU8aStream(res, u8aOut, { returnType: 'success', returnMsg: 'need to parse' })
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
//_fileHash
|
|
721
|
+
let _fileHash = await fsGetFileXxHash(pathFile)
|
|
697
722
|
// console.log('path', pathFile)
|
|
698
723
|
// console.log('hash(front)', fileHash)
|
|
699
|
-
// console.log('hash(backend)',
|
|
724
|
+
// console.log('hash(backend)', _fileHash)
|
|
700
725
|
// console.log('')
|
|
701
726
|
|
|
702
727
|
//check
|
|
703
|
-
if (fileHash !==
|
|
728
|
+
if (fileHash !== _fileHash) {
|
|
704
729
|
let out = {
|
|
705
730
|
success: {
|
|
706
731
|
existed: false,
|
|
707
|
-
msg: 'not equal',
|
|
732
|
+
msg: 'not equal hash',
|
|
708
733
|
},
|
|
709
734
|
}
|
|
710
735
|
let u8aOut = obj2u8arr(out)
|
|
@@ -1406,7 +1431,7 @@ function WConverhpServer(opt = {}) {
|
|
|
1406
1431
|
apiRoutes = [
|
|
1407
1432
|
...apiRoutes,
|
|
1408
1433
|
apiMain,
|
|
1409
|
-
|
|
1434
|
+
apiUploadCheck,
|
|
1410
1435
|
apiUploadSlice,
|
|
1411
1436
|
apiUploadSliceMerge,
|
|
1412
1437
|
apiDownloadGetFilename,
|
|
@@ -1427,7 +1452,7 @@ function WConverhpServer(opt = {}) {
|
|
|
1427
1452
|
|
|
1428
1453
|
//start
|
|
1429
1454
|
if (get(opt, 'serverHapi')) {
|
|
1430
|
-
server.route([apiMain,
|
|
1455
|
+
server.route([apiMain, apiUploadCheck, apiUploadSlice, apiUploadSliceMerge, apiDownloadGetFilename, apiDownloadGetFile, apiDownload])
|
|
1431
1456
|
}
|
|
1432
1457
|
else {
|
|
1433
1458
|
startServer()
|