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

Function one

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

Source from the content-addressed store, hash-verified

77 }
78
79 function one () {
80 debug('Receving one file')
81 const { slug, link, 'content-type': contentType } = req.headers
82 const links = header.parseMetadataFromHeader(link)
83 const mimeType = contentType ? contentType.replace(/\s*;.*/, '') : ''
84 const extension = mimeType in extensions ? `.${extensions[mimeType][0]}` : ''
85 debug('slug ' + slug)
86 debug('extension ' + extension)
87 debug('containerPath ' + containerPath)
88 debug('contentType ' + contentType)
89 debug('links ' + JSON.stringify(links))
90 ldp.post(req.hostname, containerPath, req,
91 { slug, extension, container: links.isBasicContainer, contentType }).then(
92 resourcePath => {
93 debug('File stored in ' + resourcePath)
94 header.addLinks(res, links)
95 res.set('Location', resourcePath)
96 res.sendStatus(201)
97 next()
98 },
99 err => next(err))
100 }
101}

Callers 1

handlerFunction · 0.85

Calls 1

postMethod · 0.45

Tested by

no test coverage detected