0

Systeminformation:

Application Information Application Name RDF4J-server
Version 2.2
Runtime Information :
Operating System Linux 3.10.0-327.36.2.el7.x86_64 (amd64)
Java Runtime Oracle Corporation OpenJDK 64-Bit Server VM (1.8.0_102)

I'm using the RDF4J api wanting to write NTriples to a repository in RDF4J server. The data is in a file and I can upload the file using workbench but using the api it throws an exception. This only occurs if the filesize is larger than 1.5MB.
If I use curl it also works with files larger than 1.5MB.

curl -X POST -H "Content-type: text/plain" --data-binary @central-ReadOnly.nt http://localhost:8080/rdf4j-server/repositories/testOfUpload/statements

So the question is. Why is failing on mimetype if file is larger than 1.5MB?
Why is the file created as a text/plain; ?
The file has been created as a .nt extension and I have added in /etc/mime.types the following

#MIME type                                      Extensions
application/n-triples                           nt

-

org.eclipse.rdf4j.query.UpdateExecutionException: Unsupported MIME type:   application/x-www-form-urlencoded
Message!!error executing transaction
org.eclipse.rdf4j.repository.RepositoryException: error executing transaction
at     org.eclipse.rdf4j.repository.sparql.SPARQLConnection.commit(SPARQLConnection.java:438)
at dk.skat.rdfconsolidation.Application.writeStatementsToRepository(Application.java:215)
at dk.skat.rdfconsolidation.Application.run(Application.java:72)
at dk.skat.rdfconsolidation.Application.main(Application.java:34)

Code:

protected void writeStatementsToRepository(String endpoint, String fileName) throws IOException {
    File inputfile = new File(fileName);

    Repository repo = new SPARQLRepository(endpoint);
    repo.initialize();

    try (RepositoryConnection con = repo.getConnection()) {
        con.begin();
        try {
            con.add(inputfile, null, RDFFormat.NTRIPLES);
            con.commit();
        } catch (RepositoryException e) {
            System.out.println("ERROR!!" + e.getCause());
            System.out.println("Message!!" + e.getMessage());
            e.printStackTrace();
            System.out.println("endpoint" + endpoint);
            System.out.println("inputfile" + inputfile);
            System.out.println("fileName" + fileName);
            con.rollback();
        }
    }
}
4

1 回答 1

1

您是否已经尝试过 HTTPRepository 而不是 SPARQLRepository?也许这可以为您解决问题。

于 2017-02-16T07:56:58.510 回答