fedora.client
Class Uploader

java.lang.Object
  extended by fedora.client.Uploader

public class Uploader
extends java.lang.Object

A client to a Fedora server's upload facility, accessed via a basic-authenticated multipart POST to the server. See server.management.UploadServlet for protocol details.

Author:
cwilper@cs.cornell.edu

Constructor Summary
Uploader(java.lang.String host, int port, java.lang.String user, java.lang.String pass)
          Construct an uploader to a certain repository as a certain user.
Uploader(java.lang.String protocol, java.lang.String host, int port, java.lang.String user, java.lang.String pass)
          Construct an uploader to a certain repository as a certain user.
 
Method Summary
static void main(java.lang.String[] args)
          Test this class by uploading the given file three times.
 java.lang.String upload(java.io.File file)
          Send a file to the server, getting back the identifier.
 java.lang.String upload(java.io.InputStream in)
          Send the data from the stream to the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Uploader

public Uploader(java.lang.String host,
                int port,
                java.lang.String user,
                java.lang.String pass)
         throws java.io.IOException
Construct an uploader to a certain repository as a certain user.

Throws:
java.io.IOException

Uploader

public Uploader(java.lang.String protocol,
                java.lang.String host,
                int port,
                java.lang.String user,
                java.lang.String pass)
         throws java.io.IOException
Construct an uploader to a certain repository as a certain user.

Throws:
java.io.IOException
Method Detail

upload

public java.lang.String upload(java.io.InputStream in)
                        throws java.io.IOException
Send the data from the stream to the server. This is less efficient than upload(File), but if you already have a stream, it's convenient. This method takes care of temporarily making a File out of the stream, making the request, and removing the temporary file. Having a File source for the upload is necessary because the content-length must be sent along with the request as per the HTTP Multipart POST protocol spec.

Throws:
java.io.IOException

upload

public java.lang.String upload(java.io.File file)
                        throws java.io.IOException
Send a file to the server, getting back the identifier.

Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
Test this class by uploading the given file three times. First, with the provided credentials, as an InputStream. Second, with the provided credentials, as a File. Third, with bogus credentials, as a File.