blob: 4fdefaea54c9352a53defa2126754a35c88943a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
'use strict'
const boundary = '-----------------------------paZqsnEHRufoShdX6fh0lUhXBP4k'
const randomContent = Buffer.from(makeString(1024 * 500), 'utf8')
const buffer = createMultipartBuffer(boundary)
function makeString (length) {
let result = ''
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
const charactersLength = characters.length
for (var i = 0; i < length; i++) { // eslint-disable-line no-var
result += characters.charAt(Math.floor(Math.random() *
charactersLength))
}
return result
}
function createMultipartBuffer (boundary) {
const payload = [
'--' + boundary,
'Content-Disposition: form-data; name="upload_file_0"; filename="1k_a.dat"',
'Content-Type: application/octet-stream',
'',
randomContent,
'--' + boundary + '--'
].join('\r\n')
return Buffer.from(payload, 'ascii')
}
module.exports = {
boundary,
buffer,
randomContent
}
|