Class FileOperation


  • public class FileOperation
    extends Object
    Provides methods for working on files in a stage.

    To access an object of this class, use Session.file.

    Since:
    1.2.0
    • Method Detail

      • put

        public PutResult[] put​(String localFileName,
                               String stageLocation,
                               Map<String,​String> options)
        Uploads the local files specified by localFileName to the stage location specified in stageLocation.

        This method returns the results as an Array of PutResult objects (one for each file). Each object represents the results of uploading a file.

        For example:

        
         Map<String, String> options = new HashMap<>();
         options.put("AUTO_COMPRESS", "FALSE");
         session.file().put("file://file_path", "@stage_name", options);
         
        Parameters:
        localFileName - The path to the local file(s) to upload. Specify the path in the following format: `file://'path_to_file'/'filename'`. (The `file://` prefix is optional.) To match multiple files in the path, you can specify the wildcard characters `*` and `?`.
        stageLocation - The stage (and prefix) where you want to upload the file(s). The `@` prefix is optional.
        options - A Map containing the names and values of optional parameters for the PUT command.
        Returns:
        An Array of PutResult objects (one object for each file uploaded).
        Since:
        1.2.0
      • put

        public PutResult[] put​(String localFileName,
                               String stageLocation)
        Uploads the local files specified by localFileName to the stage location specified in stageLocation.

        This method returns the results as an Array of PutResult objects (one for each file). Each object represents the results of uploading a file.

        For example:

        
         session.file().put("file://file_path", "@stage_name");
         
        Parameters:
        localFileName - The path to the local file(s) to upload. Specify the path in the following format: `file://'path_to_file'/'filename'`. (The `file://` prefix is optional.) To match multiple files in the path, you can specify the wildcard characters `*` and `?`.
        stageLocation - The stage (and prefix) where you want to upload the file(s). The `@` prefix is optional.
        Returns:
        An Array of PutResult objects (one object for each file uploaded).
        Since:
        1.2.0
      • get

        public GetResult[] get​(String stageLocation,
                               String targetDirectory,
                               Map<String,​String> options)
        Downloads the specified files from a path in a stage (specified by stageLocation) to the local directory specified by targetLocation.

        This method returns the results as an Array of GetResult objects (one for each file). Each object represents the results of downloading a file.

        For example:

        
         Map<String, String> options = new HashMap<>();
         options.put("PATTERN", "'.*.csv'");
         session.file().get("@stage_name/", "file:///tmp/", options);
         
        Parameters:
        stageLocation - The location (a directory or filename on a stage) from which you want to download the files. The `@` prefix is optional.
        targetDirectory - The path to the local directory where the file(s) should be downloaded. Specify the path in the following format: `file://'path_to_file'/'filename'`. If targetDirectory does not already exist, the method creates the directory.
        options - A Map containing the names and values of optional parameters for the GET command.
        Returns:
        An Array of PutResult objects (one object for each file downloaded).
        Since:
        1.2.0
      • get

        public GetResult[] get​(String stageLocation,
                               String targetDirectory)
        Downloads the specified files from a path in a stage (specified by stageLocation) to the local directory specified by targetLocation.

        This method returns the results as an Array of GetResult objects (one for each file). Each object represents the results of downloading a file.

        For example:

        
         getSession().file().get("@stage_name/", "file:///tmp/");
         
        Parameters:
        stageLocation - The location (a directory or filename on a stage) from which you want to download the files. The `@` prefix is optional.
        targetDirectory - The path to the local directory where the file(s) should be downloaded. Specify the path in the following format: `file://'path_to_file'/'filename'`. If targetDirectory does not already exist, the method creates the directory.
        Returns:
        An Array of PutResult objects (one object for each file downloaded).
        Since:
        1.2.0
      • uploadStream

        public void uploadStream​(String stageLocation,
                                 InputStream inputStream,
                                 boolean compress)
        Method to compress data from a stream and upload it at a stage location. The data will be uploaded as one file. No splitting is done in this method.

        caller is responsible for releasing the inputStream after the method is called.

        Parameters:
        stageLocation - Full stage path to the file
        inputStream - Input stream from which the data will be uploaded
        compress - Compress data or not before uploading stream
        Since:
        1.4.0
      • downloadStream

        public InputStream downloadStream​(String stageLocation,
                                          boolean decompress)
        Download file from the given stage and return an input stream
        Parameters:
        stageLocation - Full stage path to the file
        decompress - True if file compressed
        Returns:
        An InputStream object
        Since:
        1.4.0