Skip to content

Commit 88f6795

Browse files
committed
Pass content type to ResourceMapper when putting resources
1 parent f696c35 commit 88f6795

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/ldp.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ class LDP {
188188
originalPath += '/'
189189
}
190190
}
191-
const { url: putUrl } = await this.resourceMapper.mapFileToUrl(
191+
const { url: putUrl, contentType } = await this.resourceMapper.mapFileToUrl(
192192
{ path: this.resourceMapper._rootPath + resourcePath, hostname: host })
193-
await ldp.put(putUrl, stream)
193+
await ldp.put(putUrl, stream, contentType)
194194
return originalPath
195195
}
196196

@@ -216,11 +216,11 @@ class LDP {
216216
const { path } = url.parse(uri)
217217
const content = await serialize(graph, uri, contentType)
218218
let stream = stringToStream(content)
219-
return await this.put(path, stream)
219+
return await this.put(path, stream, contentType)
220220
}
221221

222-
async put (url, stream) {
223-
const { path: filePath } = await this.resourceMapper.mapUrlToFile({ url })
222+
async put (url, stream, contentType) {
223+
const { path: filePath } = await this.resourceMapper.mapUrlToFile({ url, contentType, createIfNotExists: true })
224224

225225
// PUT requests not supported on containers. Use POST instead
226226
if (filePath.endsWith('/')) {
@@ -323,7 +323,7 @@ class LDP {
323323
return this.graph(uri, uri, contentType)
324324
}
325325

326-
async graph (url, baseUri, contentType = 'text/turtle') {
326+
async graph (url, baseUri, contentType = DEFAULT_CONTENT_TYPE) {
327327
const body = await this.readResource(url)
328328
return new Promise((resolve, reject) => {
329329
const graph = $rdf.graph()

0 commit comments

Comments
 (0)