prepend Numerical ID , the url of the real created file ?
scenaristeur opened this issue · 4 comments
scenaristeur commented
the https://github.com/jeff-zucker/solid-file-client/ uses the solid.auth.fetch(url,request).
createFile(URL,contentType)
fileClient.createFile(newFile).then(success => {
console.log(`Created file ${newFile}.`);
}, err => console.log(err) );
This method creates a new empty file. The contentType should be specified either in the URL's extension or in the contentType parameter, but not both.
NOTE : if the file already exists, the solid.community server (and others) will create an additional file with a prepended numerical ID
jeff-zucker/solid-file-client#8
So is it possible to retrieve that prepend Numerical ID , the url of the real created file ?
RubenVerborgh commented
The Content-Location
response header should provide that for you. Does that work?
scenaristeur commented
yes , it sounds good, the real url could be retrieved with
var location = response.headers.get('location')
var file = location.substr(location.lastIndexOf('/') + 1)
var url = parentFolder+file;
RubenVerborgh commented
var file = location.substr(location.lastIndexOf('/') + 1)
var url = parentFolder+file;
That worries me a bit, should probably be:
const url = new URL(location, parentFolder);
scenaristeur commented
Txs