MCPcopy Index your code
hub / github.com/nodeSolidServer/node-solid-server / multi

Function multi

lib/handlers/post.mjs:51–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49 }
50
51 function multi () {
52 debug('receving multiple files')
53
54 const busboy = new Busboy({ headers: req.headers })
55 busboy.on('file', async function (fieldname, file, filename, encoding, mimetype) {
56 debug('One file received via multipart: ' + filename)
57 const { url: putUrl } = await ldp.resourceMapper.mapFileToUrl(
58 { path: ldp.resourceMapper._rootPath + path.join(containerPath, filename), hostname: req.hostname })
59 try {
60 await ldp.put(putUrl, file, mimetype)
61 } catch (err) {
62 busboy.emit('error', err)
63 }
64 })
65 busboy.on('error', function (err) {
66 debug('Error receiving the file: ' + err.message)
67 next(HTTPError(500, 'Error receiving the file'))
68 })
69
70 // Handled by backpressure of streams!
71 busboy.on('finish', function () {
72 debug('Done storing files')
73 res.sendStatus(200)
74 next()
75 })
76 req.pipe(busboy)
77 }
78
79 function one () {
80 debug('Receving one file')

Callers 1

handlerFunction · 0.85

Calls 3

HTTPErrorFunction · 0.85
mapFileToUrlMethod · 0.80
putMethod · 0.80

Tested by

no test coverage detected