여기 여기 당신이 파일에 경로를 사용하여 Node.js를에서 파일을로드 할 수 있습니다 내 코드 샘플 (옵션이다. 경로는 /uploads/123.owl 일 수 있음)
rdfstore.create(function(err, store) {
if (err)
console.log("There was an error creating the store", err);
else
{
//replace/with \
var syncPath = __dirname + options.path; //local but not enough
var re = new RegExp('/', 'g');
syncPath = syncPath.replace(re, '\\'); //update path
//set full path from filesystem of the ontology
var ontology = fs.readFileSync(__dirname + options.path).toString();
//LOCAL
store.load("application/ld+json" , ontology, "graph", function(err, results) {
if (err)
console.log("There was an error loading the store", err);
else
{
store.graph("graph", function(err, graph) {
if (err)
{
console.log("There was an error creating the graph", err);
}
else
{
var triples = graph.toArray();
console.log("Constructing triples sync... ");
console.log("There are ", triples.length, "triples");
if (triples.length !== 0)
{
cb(triples); }
}
}); //graph
}
});
store.close(); //done
}//err