Package chemaxon.util

Class UploadThread

java.lang.Object
java.lang.Thread
chemaxon.util.UploadThread
All Implemented Interfaces:
Runnable

@PublicAPI public class UploadThread extends Thread
Class for uploading a file from the client side to the server side via HTML forms using a thread.
  • Constructor Details

    • UploadThread

      public UploadThread()
  • Method Details

    • setParams

      public void setParams(String type, int length, InputStream is)
      Setting parameters. Calling this the file selected on the client side will be saved in a string, won't be saved as a file. The content of the file can be obtained by getFileContent().
      Parameters:
      type - The type of the request, can be determined by the request.getContentType() function.
      length - The length of the request, can be determined by the request.getContentLength() function.
      is - The inputstream of the request, can be determined by the request.getInputStream() function.
    • setParams

      public void setParams(String type, int length, InputStream is, String dir)
      Seting parameters. Calling this the file selected on the client side will be saved on the server side with its original name.
      Parameters:
      type - The type of the request, can be determined by the request.getContentType() method.
      length - The length of the request, can be determined by the request.getContentLength() method.
      is - The inputstream of the request, can be determined by the request.getInputStream() method.
      dir - The directory of the server in which the file will be saved with its original name.
    • setParams

      public void setParams(String type, int length, InputStream is, String dir, String tmp)
      Setting the parameters. Calling this the file selected on the client side will be saved on the server side as savedFileName.
      Parameters:
      type - The type of the request, can be determined by the request.getContentType() funtion.
      length - The length of the request, can be determined by the request.getContentLength() funtion.
      is - The inputstream of the request, can be determined by the request.getInputStream() funtion.
      dir - The directory of the server in which the file will be saved.
      tmp - The name of the file as which it will be saved in the dir directory.
    • getFileContent

      public String getFileContent()
      Returns the file content, if the selected file haven't been saved on the server side.
      Returns:
      the content of the file as String
    • getData

      public int getData()
      Returns the saved data in bytes.
      Returns:
      the amount of data saved.
    • getFileName

      public String getFileName()
      Returns the name of saved file.
      Returns:
      the name of the saved file
    • getFile

      public File getFile()
      Returns the file object.
      Returns:
      the file
    • getFileSize

      public int getFileSize()
      Returns the size of saved file.
      Returns:
      the size of the file
    • getDefaultFileName

      public String getDefaultFileName()
      Returns the original name of saved file.
      Returns:
      the default file name
    • getParameterNames

      public Enumeration<String> getParameterNames()
      Returns the names of parameters posted by the HTML form.
      Returns:
      an enumeration of all parameter names
    • getParameter

      public String getParameter(String name)
      Returns the value of parameter posted by the HTML form.
      Parameters:
      name - Name of the parameter.
      Returns:
      the parameter value
    • isFinished

      public boolean isFinished()
      Check the current state.
      Returns:
      true if uploading has finished, else returns false.
    • setFinished

      public void setFinished(boolean f)
      Finishes the upload process.
      Parameters:
      f - new value for finished
    • getPercent

      public int getPercent()
      Returns the rate of saved data and whole data.
      Returns:
      current percent
    • run

      public void run()
      Starts uploading.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • getSuccess

      public boolean getSuccess()
      Indicates if the operation was successful.
      Returns:
      true, if the file was saved successfully
    • getError

      public Exception getError()
      For retrieving stored exceptions.
      Returns:
      the Exception, or null if there were no exceptions.