w-converhp 2.0.4 → 2.0.6
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 +6 -6
- 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 +1 -1
- package/docs/WConverhpClient.mjs.html +4 -4
- package/docs/WConverhpServer.html +3 -3
- package/docs/WConverhpServer.mjs.html +33 -85
- package/docs/index.html +1 -1
- package/package.json +2 -2
- package/scla.mjs +8 -3
- package/sclb.mjs +9 -3
- package/sclc.mjs +10 -4
- package/src/WConverhpClient.mjs +3 -3
- package/src/WConverhpServer.mjs +31 -83
- package/src/mergeFiles.mjs +96 -0
- package/src/mergeFiles.wk.umd.js +1 -0
- package/srv.mjs +18 -13
- package/test/1mb.7z +0 -0
- package/test/executeWithFile.test.mjs +191 -0
- package/test/executeWithU8a.test.mjs +185 -0
- package/test/uploadLargeFile.test.mjs +149 -0
- package/toolg/gDistRollup.mjs +56 -47
- package/test/all.test.mjs +0 -10
|
@@ -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#line118">line 118</a>
|
|
84
84
|
</li></ul></dd>
|
|
85
85
|
|
|
86
86
|
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
|
|
128
128
|
<h5 class="h5-examples">Example</h5>
|
|
129
129
|
|
|
130
|
-
<pre class="prettyprint"><code>import _ from 'lodash-es'
|
|
131
130
|
port: 8080,
|
|
132
131
|
apiName: 'api',
|
|
133
132
|
pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
|
|
134
133
|
funCheck: () => {
|
|
135
134
|
return true
|
|
136
135
|
},
|
|
137
136
|
// console.log(`Server[port:${opt.port}]: execute`, func, input)
|
|
138
137
|
console.log(`Server[port:${opt.port}]: execute`, func)
|
|
139
138
|
try {
|
|
140
139
|
if (func === 'add') {
|
|
141
140
|
if (_.get(input, 'p.d.u8a', null)) {
|
|
142
141
|
console.log('input.p.d.u8a', input.p.d.u8a)
|
|
143
142
|
}
|
|
144
143
|
let r = {
|
|
145
144
|
_add: input.p.a + input.p.b,
|
|
146
145
|
_data: [11, 22.22, 'abc', { x: '21', y: 65.43, z: 'test中文' }],
|
|
147
146
|
_bin: {
|
|
148
147
|
name: 'zdata.b2',
|
|
149
148
|
u8a: new Uint8Array([66, 97, 115]),
|
|
150
149
|
// name: '100mb.7z',
|
|
151
150
|
// u8a: new Uint8Array(fs.readFileSync('D:\\開源-JS-006-2-w-converhp\\_temp\\100mb.7z')),
|
|
152
151
|
// name: '500mb.7z',
|
|
153
152
|
// u8a: new Uint8Array(fs.readFileSync('D:\\開源-JS-006-2-w-converhp\\_temp\\500mb.7z')),
|
|
154
153
|
// name: '1000mb.7z',
|
|
155
154
|
// u8a: new Uint8Array(fs.readFileSync('D:\\開源-JS-006-2-w-converhp\\_temp\\1000mb.7z')),
|
|
156
155
|
},
|
|
157
156
|
}
|
|
158
157
|
pm.resolve(r)
|
|
159
158
|
}
|
|
160
159
|
else {
|
|
161
160
|
console.log('invalid func')
|
|
162
161
|
pm.reject('invalid func')
|
|
163
162
|
}
|
|
164
163
|
}
|
|
165
164
|
catch (err) {
|
|
166
165
|
console.log('execute error', err)
|
|
167
166
|
pm.reject('execute error')
|
|
168
167
|
}
|
|
169
168
|
console.log(`Server[port:${opt.port}]: upload`, input)
|
|
170
169
|
try {
|
|
171
170
|
let output = input
|
|
172
171
|
pm.resolve(output)
|
|
173
172
|
}
|
|
174
173
|
catch (err) {
|
|
175
174
|
console.log('execute error', err)
|
|
176
175
|
pm.reject('execute error')
|
|
177
176
|
}
|
|
178
177
|
// console.log(`Server[port:${opt.port}]: handler`, data)
|
|
178
|
+
<pre class="prettyprint"><code>import _ from 'lodash-es'
|
|
179
179
|
port: 8080,
|
|
180
180
|
apiName: 'api',
|
|
181
181
|
pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
|
|
182
182
|
funCheck: () => {
|
|
183
183
|
return true
|
|
184
184
|
},
|
|
185
185
|
// console.log(`Server[port:${opt.port}]: execute`, func, input)
|
|
186
186
|
console.log(`Server[port:${opt.port}]: execute`, func)
|
|
187
187
|
try {
|
|
188
188
|
if (func === 'add') {
|
|
189
189
|
if (_.get(input, 'p.d.u8a', null)) {
|
|
190
190
|
console.log('input.p.d.u8a', input.p.d.u8a)
|
|
191
191
|
}
|
|
192
192
|
let r = {
|
|
193
193
|
_add: input.p.a + input.p.b,
|
|
194
194
|
_data: [11, 22.22, 'abc', { x: '21', y: 65.43, z: 'test中文' }],
|
|
195
195
|
_bin: {
|
|
196
196
|
name: 'zdata.b2',
|
|
197
197
|
u8a: new Uint8Array([66, 97, 115]),
|
|
198
198
|
// name: '100mb.7z',
|
|
199
199
|
// u8a: new Uint8Array(fs.readFileSync('D:\\開源-JS-006-2-w-converhp\\_temp\\100mb.7z')),
|
|
200
200
|
// name: '500mb.7z',
|
|
201
201
|
// u8a: new Uint8Array(fs.readFileSync('D:\\開源-JS-006-2-w-converhp\\_temp\\500mb.7z')),
|
|
202
202
|
// name: '1000mb.7z',
|
|
203
203
|
// u8a: new Uint8Array(fs.readFileSync('D:\\開源-JS-006-2-w-converhp\\_temp\\1000mb.7z')),
|
|
204
204
|
},
|
|
205
205
|
}
|
|
206
206
|
pm.resolve(r)
|
|
207
207
|
}
|
|
208
208
|
else {
|
|
209
209
|
console.log('invalid func')
|
|
210
210
|
pm.reject('invalid func')
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
catch (err) {
|
|
214
214
|
console.log('execute error', err)
|
|
215
215
|
pm.reject('execute error')
|
|
216
216
|
}
|
|
217
217
|
console.log(`Server[port:${opt.port}]: upload`, input)
|
|
218
218
|
try {
|
|
219
219
|
let output = input
|
|
220
220
|
pm.resolve(output)
|
|
221
221
|
}
|
|
222
222
|
catch (err) {
|
|
223
223
|
console.log('upload error', err)
|
|
224
224
|
pm.reject('upload error')
|
|
225
225
|
}
|
|
226
226
|
// console.log(`Server[port:${opt.port}]: handler`, data)
|
|
227
227
|
|
|
228
228
|
|
|
229
229
|
|
|
@@ -709,7 +709,7 @@
|
|
|
709
709
|
<br class="clear">
|
|
710
710
|
|
|
711
711
|
<footer>
|
|
712
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
712
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 01 2025 13:07:46 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
713
713
|
</footer>
|
|
714
714
|
|
|
715
715
|
<script>prettyPrint();</script>
|
|
@@ -45,11 +45,10 @@
|
|
|
45
45
|
|
|
46
46
|
<section>
|
|
47
47
|
<article>
|
|
48
|
-
<pre class="prettyprint source linenums"><code>import
|
|
49
|
-
import
|
|
48
|
+
<pre class="prettyprint source linenums"><code>import fs from 'fs'
|
|
49
|
+
import stream from 'stream'
|
|
50
50
|
import Hapi from '@hapi/hapi'
|
|
51
51
|
import Inert from '@hapi/inert' //提供靜態檔案
|
|
52
|
-
import stream from 'stream'
|
|
53
52
|
import get from 'lodash-es/get.js'
|
|
54
53
|
import genPm from 'wsemi/src/genPm.mjs'
|
|
55
54
|
import iseobj from 'wsemi/src/iseobj.mjs'
|
|
@@ -66,8 +65,8 @@ import obj2u8arr from 'wsemi/src/obj2u8arr.mjs'
|
|
|
66
65
|
import u8arr2obj from 'wsemi/src/u8arr2obj.mjs'
|
|
67
66
|
import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
|
|
68
67
|
import fsCreateFolder from 'wsemi/src/fsCreateFolder.mjs'
|
|
69
|
-
import
|
|
70
|
-
import
|
|
68
|
+
import mergeFiles from './mergeFiles.wk.umd.js'
|
|
69
|
+
// import mergeFiles from './mergeFiles.mjs'
|
|
71
70
|
|
|
72
71
|
|
|
73
72
|
/**
|
|
@@ -103,7 +102,7 @@ import fsDeleteFile from 'wsemi/src/fsDeleteFile.mjs'
|
|
|
103
102
|
* //new
|
|
104
103
|
* let wo = new WConverhpServer(opt)
|
|
105
104
|
*
|
|
106
|
-
* wo.on('execute',
|
|
105
|
+
* wo.on('execute', (func, input, pm) => {
|
|
107
106
|
* // console.log(`Server[port:${opt.port}]: execute`, func, input)
|
|
108
107
|
* console.log(`Server[port:${opt.port}]: execute`, func)
|
|
109
108
|
*
|
|
@@ -145,7 +144,7 @@ import fsDeleteFile from 'wsemi/src/fsDeleteFile.mjs'
|
|
|
145
144
|
* }
|
|
146
145
|
*
|
|
147
146
|
* })
|
|
148
|
-
* wo.on('upload',
|
|
147
|
+
* wo.on('upload', (input, pm) => {
|
|
149
148
|
* console.log(`Server[port:${opt.port}]: upload`, input)
|
|
150
149
|
*
|
|
151
150
|
* try {
|
|
@@ -153,12 +152,12 @@ import fsDeleteFile from 'wsemi/src/fsDeleteFile.mjs'
|
|
|
153
152
|
* pm.resolve(output)
|
|
154
153
|
* }
|
|
155
154
|
* catch (err) {
|
|
156
|
-
* console.log('
|
|
157
|
-
* pm.reject('
|
|
155
|
+
* console.log('upload error', err)
|
|
156
|
+
* pm.reject('upload error')
|
|
158
157
|
* }
|
|
159
158
|
*
|
|
160
159
|
* })
|
|
161
|
-
* wo.on('handler',
|
|
160
|
+
* wo.on('handler', (data) => {
|
|
162
161
|
* // console.log(`Server[port:${opt.port}]: handler`, data)
|
|
163
162
|
* })
|
|
164
163
|
*
|
|
@@ -244,6 +243,10 @@ function WConverhpServer(opt = {}) {
|
|
|
244
243
|
//host: 'localhost',
|
|
245
244
|
port,
|
|
246
245
|
routes: {
|
|
246
|
+
timeout: {
|
|
247
|
+
server: false, //關閉伺服器超時
|
|
248
|
+
socket: false, //關閉socket超時
|
|
249
|
+
},
|
|
247
250
|
cors: {
|
|
248
251
|
origin: corsOrigins, //Access-Control-Allow-Origin
|
|
249
252
|
credentials: false, //Access-Control-Allow-Credentials
|
|
@@ -360,8 +363,8 @@ function WConverhpServer(opt = {}) {
|
|
|
360
363
|
parse: false,
|
|
361
364
|
},
|
|
362
365
|
timeout: {
|
|
363
|
-
|
|
364
|
-
|
|
366
|
+
server: false, //關閉伺服器超時
|
|
367
|
+
socket: false, //關閉socket超時
|
|
365
368
|
},
|
|
366
369
|
},
|
|
367
370
|
handler: async function (req, res) {
|
|
@@ -518,8 +521,8 @@ function WConverhpServer(opt = {}) {
|
|
|
518
521
|
parse: false,
|
|
519
522
|
},
|
|
520
523
|
timeout: {
|
|
521
|
-
|
|
522
|
-
|
|
524
|
+
server: false, //關閉伺服器超時
|
|
525
|
+
socket: false, //關閉socket超時
|
|
523
526
|
},
|
|
524
527
|
},
|
|
525
528
|
handler: async function (req, res) {
|
|
@@ -664,8 +667,8 @@ function WConverhpServer(opt = {}) {
|
|
|
664
667
|
parse: true, //前端送obj過來
|
|
665
668
|
},
|
|
666
669
|
timeout: {
|
|
667
|
-
|
|
668
|
-
|
|
670
|
+
server: false, //關閉伺服器超時
|
|
671
|
+
socket: false, //關閉socket超時
|
|
669
672
|
},
|
|
670
673
|
},
|
|
671
674
|
handler: async function (req, res) {
|
|
@@ -739,78 +742,13 @@ function WConverhpServer(opt = {}) {
|
|
|
739
742
|
return res.response({ error: 'invalid packageId in payload' }).code(400)
|
|
740
743
|
}
|
|
741
744
|
|
|
742
|
-
//merge
|
|
743
|
-
let merge = async () => {
|
|
744
|
-
let errTemp = ''
|
|
745
|
-
|
|
746
|
-
//pathFileMerge
|
|
747
|
-
let pathFileMerge = path.join(pathUploadTemp, `${packageId}`)
|
|
748
|
-
// console.log('pathFileMerge', pathFileMerge)
|
|
749
|
-
|
|
750
|
-
//fileStream
|
|
751
|
-
let fileStream = fs.createWriteStream(pathFileMerge)
|
|
752
|
-
// console.log(`merge filename[${filename}] start`)
|
|
753
|
-
|
|
754
|
-
//使用try catch攔截,使stream能完整創造與結束
|
|
755
|
-
try {
|
|
756
|
-
for (let i = 0; i < chunkTotal; i++) {
|
|
757
|
-
// console.log(`merge ${i + 1}/${chunkTotal}`)
|
|
758
|
-
|
|
759
|
-
//chunkIndex
|
|
760
|
-
let chunkIndex = i
|
|
761
|
-
|
|
762
|
-
//pathFileChunk
|
|
763
|
-
let pathFileChunk = path.join(pathUploadTemp, `${packageId}_${chunkIndex}`)
|
|
764
|
-
|
|
765
|
-
//check
|
|
766
|
-
if (!fsIsFile(pathFileChunk)) {
|
|
767
|
-
// console.log(`pathFileChunk[${pathFileChunk}] is not a file`)
|
|
768
|
-
throw new Error(`Missing chunk ${i} of filename[${filename}]`)
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
// console.log(`merging chunk[${chunkIndex + 1}/${chunkTotal}]...`)
|
|
772
|
-
|
|
773
|
-
//chunkData
|
|
774
|
-
let chunkData = fs.readFileSync(pathFileChunk)
|
|
775
|
-
|
|
776
|
-
//write
|
|
777
|
-
fileStream.write(chunkData)
|
|
778
|
-
|
|
779
|
-
//fsDeleteFile
|
|
780
|
-
fsDeleteFile(pathFileChunk)
|
|
781
|
-
|
|
782
|
-
// console.log(`merge chunk[${chunkIndex + 1}/${chunkTotal}] done`)
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
catch (err) {
|
|
786
|
-
errTemp = err.message
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
//end
|
|
790
|
-
fileStream.end()
|
|
791
|
-
// console.log(`merge filename[${filename}] done`)
|
|
792
|
-
|
|
793
|
-
//check
|
|
794
|
-
if (isestr(errTemp)) {
|
|
795
|
-
return Promise.reject(errTemp)
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
//r
|
|
799
|
-
let r = {
|
|
800
|
-
// message: `Merged filename[${filename}] successfully`,
|
|
801
|
-
filename,
|
|
802
|
-
path: pathFileMerge,
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
return r
|
|
806
|
-
}
|
|
807
|
-
|
|
808
745
|
//core
|
|
809
746
|
let core = async() => {
|
|
810
747
|
|
|
811
748
|
//merge
|
|
812
749
|
// console.log('merge start')
|
|
813
|
-
let r = await merge()
|
|
750
|
+
// let r = await merge()
|
|
751
|
+
let r = await mergeFiles(pathUploadTemp, packageId, chunkTotal, filename)
|
|
814
752
|
// console.log('merge done', r)
|
|
815
753
|
|
|
816
754
|
//procUpload
|
|
@@ -828,6 +766,7 @@ function WConverhpServer(opt = {}) {
|
|
|
828
766
|
out.success = msg
|
|
829
767
|
})
|
|
830
768
|
.catch(function(msg) {
|
|
769
|
+
console.log('bbb msg', msg)
|
|
831
770
|
out.error = msg
|
|
832
771
|
})
|
|
833
772
|
// console.log('out', out)
|
|
@@ -886,12 +825,21 @@ function WConverhpServer(opt = {}) {
|
|
|
886
825
|
|
|
887
826
|
//start
|
|
888
827
|
if (get(opt, 'serverHapi')) {
|
|
889
|
-
opt.serverHapi.route([apiMain, apiSlice, apiSliceMerge])
|
|
828
|
+
// opt.serverHapi.route([apiMain, apiSlice, apiSliceMerge])
|
|
829
|
+
server.route([apiMain, apiSlice, apiSliceMerge])
|
|
890
830
|
}
|
|
891
831
|
else {
|
|
892
832
|
startServer()
|
|
893
833
|
}
|
|
894
834
|
|
|
835
|
+
//stop
|
|
836
|
+
let stop = () => {
|
|
837
|
+
server.stop()
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
//save
|
|
841
|
+
ee.stop = stop
|
|
842
|
+
|
|
895
843
|
return ee
|
|
896
844
|
}
|
|
897
845
|
|
|
@@ -911,7 +859,7 @@ export default WConverhpServer
|
|
|
911
859
|
<br class="clear">
|
|
912
860
|
|
|
913
861
|
<footer>
|
|
914
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
862
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 01 2025 13:07:46 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
915
863
|
</footer>
|
|
916
864
|
|
|
917
865
|
<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 Tue Apr 01 2025 13:07:46 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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-converhp",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"main": "dist/w-converhp-server.umd.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/hapi": "^21.4.0",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"form-data": "^4.0.2",
|
|
14
|
-
"w-package-tools": "^1.0.
|
|
14
|
+
"w-package-tools": "^1.0.85"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"@hapi/hapi": "^20.2.1",
|
package/scla.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import w from 'wsemi'
|
|
|
3
3
|
import FormData from 'form-data'
|
|
4
4
|
import WConverhpClient from './src/WConverhpClient.mjs'
|
|
5
5
|
|
|
6
|
+
let ms = []
|
|
6
7
|
|
|
7
8
|
let opt = {
|
|
8
9
|
FormData,
|
|
@@ -16,7 +17,7 @@ let opt = {
|
|
|
16
17
|
//new
|
|
17
18
|
let wo = new WConverhpClient(opt)
|
|
18
19
|
|
|
19
|
-
wo.on('error',
|
|
20
|
+
wo.on('error', (err) => {
|
|
20
21
|
console.log(`error`, err)
|
|
21
22
|
})
|
|
22
23
|
|
|
@@ -33,6 +34,7 @@ async function execute(name, u8a) {
|
|
|
33
34
|
},
|
|
34
35
|
}
|
|
35
36
|
console.log('p', p)
|
|
37
|
+
ms.push({ 'execute input': p })
|
|
36
38
|
|
|
37
39
|
//execute
|
|
38
40
|
await wo.execute('add', { p },
|
|
@@ -46,8 +48,9 @@ async function execute(name, u8a) {
|
|
|
46
48
|
})
|
|
47
49
|
.then(function(r) {
|
|
48
50
|
console.log('client web: execute: add', r)
|
|
49
|
-
console.log('r._bin.name', r._bin.name, 'r._bin.u8a', r._bin.u8a)
|
|
51
|
+
// console.log('r._bin.name', r._bin.name, 'r._bin.u8a', r._bin.u8a)
|
|
50
52
|
// w.downloadFileFromU8Arr(r._bin.name, r._bin.u8a)
|
|
53
|
+
ms.push({ 'execute output': r })
|
|
51
54
|
})
|
|
52
55
|
.catch(function (err) {
|
|
53
56
|
console.log('client web: execute: catch', err)
|
|
@@ -60,11 +63,13 @@ function executeWithU8a() {
|
|
|
60
63
|
|
|
61
64
|
//u8a
|
|
62
65
|
let u8a = new Uint8Array([66, 97, 115])
|
|
63
|
-
console.log('executeWithU8a u8a', u8a)
|
|
66
|
+
// console.log('executeWithU8a u8a', u8a)
|
|
64
67
|
|
|
65
68
|
//execute
|
|
66
69
|
await execute('zdata.b1', u8a)
|
|
67
70
|
|
|
71
|
+
console.log('ms', JSON.stringify(ms))
|
|
72
|
+
|
|
68
73
|
}
|
|
69
74
|
core()
|
|
70
75
|
}
|
package/sclb.mjs
CHANGED
|
@@ -4,6 +4,8 @@ import FormData from 'form-data'
|
|
|
4
4
|
import WConverhpClient from './src/WConverhpClient.mjs'
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
let ms = []
|
|
8
|
+
|
|
7
9
|
let opt = {
|
|
8
10
|
FormData,
|
|
9
11
|
url: 'http://localhost:8080',
|
|
@@ -16,7 +18,7 @@ let opt = {
|
|
|
16
18
|
//new
|
|
17
19
|
let wo = new WConverhpClient(opt)
|
|
18
20
|
|
|
19
|
-
wo.on('error',
|
|
21
|
+
wo.on('error', (err) => {
|
|
20
22
|
console.log(`error`, err)
|
|
21
23
|
})
|
|
22
24
|
|
|
@@ -33,6 +35,7 @@ async function execute(name, u8a) {
|
|
|
33
35
|
},
|
|
34
36
|
}
|
|
35
37
|
console.log('p', p)
|
|
38
|
+
ms.push({ 'execute input': p })
|
|
36
39
|
|
|
37
40
|
//execute
|
|
38
41
|
await wo.execute('add', { p },
|
|
@@ -46,8 +49,9 @@ async function execute(name, u8a) {
|
|
|
46
49
|
})
|
|
47
50
|
.then(function(r) {
|
|
48
51
|
console.log('client web: execute: add', r)
|
|
49
|
-
console.log('r._bin.name', r._bin.name, 'r._bin.u8a', r._bin.u8a)
|
|
52
|
+
// console.log('r._bin.name', r._bin.name, 'r._bin.u8a', r._bin.u8a)
|
|
50
53
|
// w.downloadFileFromU8Arr(r._bin.name, r._bin.u8a)
|
|
54
|
+
ms.push({ 'execute output': r })
|
|
51
55
|
})
|
|
52
56
|
.catch(function (err) {
|
|
53
57
|
console.log('client web: execute: catch', err)
|
|
@@ -60,11 +64,13 @@ function executeWithFile() {
|
|
|
60
64
|
|
|
61
65
|
//u8a
|
|
62
66
|
let u8a = new Uint8Array(fs.readFileSync('../_data/10mb.7z'))
|
|
63
|
-
console.log('executeWithFile u8a', u8a)
|
|
67
|
+
// console.log('executeWithFile u8a', u8a)
|
|
64
68
|
|
|
65
69
|
//execute
|
|
66
70
|
await execute('10mb.7z', u8a)
|
|
67
71
|
|
|
72
|
+
console.log('ms', ms)
|
|
73
|
+
|
|
68
74
|
}
|
|
69
75
|
core()
|
|
70
76
|
}
|
package/sclc.mjs
CHANGED
|
@@ -4,6 +4,8 @@ import FormData from 'form-data'
|
|
|
4
4
|
import WConverhpClient from './src/WConverhpClient.mjs'
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
let ms = []
|
|
8
|
+
|
|
7
9
|
let opt = {
|
|
8
10
|
FormData,
|
|
9
11
|
url: 'http://localhost:8080',
|
|
@@ -16,7 +18,7 @@ let opt = {
|
|
|
16
18
|
//new
|
|
17
19
|
let wo = new WConverhpClient(opt)
|
|
18
20
|
|
|
19
|
-
wo.on('error',
|
|
21
|
+
wo.on('error', (err) => {
|
|
20
22
|
console.log(`error`, err)
|
|
21
23
|
})
|
|
22
24
|
|
|
@@ -24,11 +26,12 @@ function uploadLargeFile() {
|
|
|
24
26
|
let core = async() => {
|
|
25
27
|
|
|
26
28
|
//u8a
|
|
27
|
-
let u8a = new Uint8Array(fs.readFileSync('../_data/
|
|
29
|
+
let u8a = new Uint8Array(fs.readFileSync('../_data/1mb.7z')) //1000mb
|
|
28
30
|
console.log('u8a.length', u8a.length)
|
|
29
|
-
console.log('uploadLargeFile u8a', u8a)
|
|
31
|
+
// console.log('uploadLargeFile u8a', u8a)
|
|
32
|
+
ms.push({ 'upload u8a.length': u8a.length })
|
|
30
33
|
|
|
31
|
-
await wo.upload('
|
|
34
|
+
await wo.upload('1mb.7z', u8a,
|
|
32
35
|
function ({ prog, p, m }) {
|
|
33
36
|
// console.log('client web: upload: prog', prog, p, m)
|
|
34
37
|
if (m === 'upload') {
|
|
@@ -37,11 +40,14 @@ function uploadLargeFile() {
|
|
|
37
40
|
})
|
|
38
41
|
.then(function(res) {
|
|
39
42
|
console.log('client web: upload: then', res)
|
|
43
|
+
ms.push({ 'upload output': res })
|
|
40
44
|
})
|
|
41
45
|
.catch(function (err) {
|
|
42
46
|
console.log('client web: upload: catch', err)
|
|
43
47
|
})
|
|
44
48
|
|
|
49
|
+
console.log('ms', ms)
|
|
50
|
+
|
|
45
51
|
}
|
|
46
52
|
core()
|
|
47
53
|
}
|
package/src/WConverhpClient.mjs
CHANGED
|
@@ -542,8 +542,8 @@ function WConverhpClient(opt) {
|
|
|
542
542
|
catch (err) {}
|
|
543
543
|
}
|
|
544
544
|
if (n === 0) {
|
|
545
|
-
eeEmit('error', `
|
|
546
|
-
return Promise.reject(`
|
|
545
|
+
eeEmit('error', `can not get size of bb`)
|
|
546
|
+
return Promise.reject(`can not get size of bb`)
|
|
547
547
|
}
|
|
548
548
|
// console.log('n', n)
|
|
549
549
|
|
|
@@ -609,7 +609,7 @@ function WConverhpClient(opt) {
|
|
|
609
609
|
}
|
|
610
610
|
|
|
611
611
|
//send merge
|
|
612
|
-
console.log(`merging tempId[${tempId}]...`)
|
|
612
|
+
// console.log(`merging tempId[${tempId}]...`)
|
|
613
613
|
let msg = {
|
|
614
614
|
'filename': tempId,
|
|
615
615
|
'chunk-total': chunkTotal,
|