0

for my program I need to be able to upload and download files to a file server for persistence. I already have an OpenLink Virtuoso Universal Server running because I want to harness it's triple store capabilities later on.

According to the specification of the server it should be possible to upload/download files via the FTP protocol. From the information I gathered I assume that I have to specify a new user that has the rights to upload files and I found a tutorial that explains how I can upload files with the Apache Commons Net API in Java (Apache Commons Net API Tutorial). After I upload a file ideally the Virtuoso server would host the file and returned an (http) URL where I can access the file while the server is running.

So my question is if someone can show me how to configure the Virtuoso Server so it is possible to upload and download files. The Virtuoso is running on localhost because I want to keep the whole program inside my development computer. I already tried uploading a file with connecting the FTPClient via:

FTPClient client = new FTPClient();
FileInputStream fis = null;

try {

    client.connect("localhost", 21);
    client.login("dba", "password");
    String filename = "text.txt";

    fis = new FileInputStream(filename);

    client.storeFile(filename, fis);
    client.logout();
} 
catch (SocketException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} 
catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

Where "dba" is the standard administrator account that is shipped with the Virtuoso server. This code refuses to connect and I get a ConnectException

java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:176)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:268)
    at ftptest.TestFTP.main(TestFTP.java:18)

The server is running but it won't connect to it. I can access the admin console via localhost:8890 so I assume the server is running.

I a novice regarding ftp-servers so please keep your answer simple. That is also the reason why I don't understand the documentation on the Virtuoso home page regarding their FTP features. Please help me to understand this topic.

If you think anything is wrong with my approach to use the Virtuoso Server please let me know.

Thank you for your effort.

Greetings

4

0 回答 0