| 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 | } |