Package Torello.Java

Class GSUTIL


  • public class GSUTIL
    extends java.lang.Object
    GSUTIL - Documentation.

    The purpose of this class is to make a few of the Google Cloud Server functions for copying files and setting their Access Control Lists a little easier.

    PLEASE NOTE: You do not need to a Google Cloud Account, or access to any Cloud accounts at all to use any of the classes in these packages. (except this one, of course) Right now (2019), I host three different domains, and use Google Corporation to do the hosting and directory structure work. Google Cloud Server has a UNIX-BASH Shell and text editor for writing Java Code, and a small command line utility for copying files to and from the Web-Server Hosting Directories named GSUTIL.

    This Java Class facilitates automating calls to GSUTIL. Repeated calls to this UNIX-BASH Executable Command can become very cumbersome, very quickly. If you are using Google Cloud Server to do either your Java Development, or your hosting (or both), then this class will help you save repeated calls to this utility inside Java files. One alternative would obviously be to write BASH Shell Scripts (".sh" executable-files), but using Java to make Operating System Commands is actually a tremendous benefit since knowing "fewer programming languages" means more in-depth knowledge... But you may disagree with me, I won't mind.

    example

    Reality Check: If you are not going to (easily) remember the command line parameters to GSUTIL quickly, and you plan to host content using GCS Storage Buckets, this class will a lot.


    Stack Overflow Question:

    Piped GSUTIL output to file. (asked May 29 '13 at 21:00) by LamdaComplex

    Greetings StackOverflow,

    I'm working on a small project on Windows which needs to read the output of GSUTIL's copy function. Problem is, the output of the copy function doesn't seem to work via the Standard Output. Also, the behaviour of GSUTIL is inconsistent: piping output doesn't work with the copy function but using the list function is does work.

    When I use the following command in my command prompt the output is displayed in the command prompt but not redirected to the text file. This command doesn't work right:

    C:\gsutil> python gsutil cp "file://C:/test_files/*" gs://gs_teststore/ > gsutil_cp.txt

    On the other hand when I use the list function (ls) the output does work through the standard output and works at I hoped:

    C:\gsutil> python gsutil ls gs://gs_teststore/ > gsutil_ls.txt

    Is there a way to capture the output from the copy function of the GSUTIL?


    ANSWER #1

    You can use the -L option to generate a manifest file of all files that were copied. From the documentation:

    • -L <file> Outputs a manifest log file with detailed information about each item that was copied. This manifest contains the following:
    • information for each item:
    • Source path
    • Destination path
    • Source size
    • Bytes transferred
    • MD5 hash
    • UTC date and time transfer was started in ISO 8601 format
    • UTC date and time transfer was completed in ISO 8601 format
    • Upload id, if a resumable upload was performed
    • Final result of the attempted upload, success or failure.
    • Failure details, if any


    UNIX or DOS Shell Commands-Block:
    $ echo "hey" | gsutil cp -L manifest.txt - gs://mybucket/hey.txt Copying from STDIN [Content-Type=application/octet-stream]... $ cat manifest.txt Source,Destination,Start,End,Md5,UploadId,Source Size,Bytes Transferred,Result,Description file://-,gs://mybucket/hey.txt,2013-05-29T21:29:31.847715Z,2013-05-29T21:29:32.115624Z,081ecc5e6dd6ba0d150fc4bc0e62ec50,,,0,OK,


    ANSWER #2

    From Google Cloud Server Team Employee

    You can use the -L option to generate a manifest file of all files that were copied. From the documentation: Jeff's answer about using gsutil cp -L is the right solution for what you're trying to do.

    Just to supplement with some detail about why you weren't able to capture the gsutil cp output the way you expected: gsutil outputs status messages to stderr, and only outputs to stdout when the output in question is the purpose of the command you're running. Thus, for example, gsutil ls outputs to stdout because that output is the purpose of the command, while in contrast, the progress indicator messages for the gsutil cp command are really status about the underlying purpose (which is copying data) -- so that output goes to stderr.

    Mike Schwartz, Google Cloud Storage team

    Static (Functional) API: The methods in this class are all (100%) defined with the Java Key-Word / Key-Concept 'static'. Furthermore, there is no way to obtain an instance of this class, because there are no public (nor private) constructors. Java's Spring-Boot, MVC feature is *not* utilized because it flies directly in the face of the light-weight data-classes philosophy. This has many advantages over the rather ornate Component Annotations (@Component, @Service, @AutoWired, etc... 'Java Beans') syntax:

    • The methods here use the key-word 'static' which means (by implication) that there is no internal-state. Without any 'internal state' there is no need for constructors in the first place! (This is often the complaint by MVC Programmers).
    • A 'Static' (Functional-Programming) API expects to use fewer data-classes, and light-weight data-classes, making it easier to understand and to program.
    • The Vectorized HTML data-model allows more user-control over HTML parse, search, update & scrape. Also, memory management, memory leakage, and the Java Garbage Collector ought to be intelligible through the 'reuse' of the standard JDK class Vector for storing HTML Web-Page data.

    The power that object-oriented programming extends to a user is (mostly) limited to data-representation. Thinking of "Services" as "Objects" (Spring-MVC, 'Java Beans') is somewhat 'over-applying' the Object Oriented Programming Model. Like most classes in the Java-HTML JAR Library, this class backtracks to a more C-Styled Functional Programming Model (no Objects) - by re-using (quite profusely) the key-word static with all of its methods, and by sticking to Java's well-understood class Vector

    Static Fields: The methods in this class do not create any internal state that is maintained - however there are a few private & static fields defined. These fields are instantiated only once during the Class Loader phase (and only if this class shall be used), and serve as data 'lookup' fields (static constants). View this class' source-code in the link provided below to see internally used data.

    There are four public, static String constants solely for the purpose of reminding the programmer what the CONTENT-TYPE HTTP Parameter is used for.

    There is also public, static Appendable for directing text-output from the invocation of these methods to terminal, or a logger (such as a StorageWriter).



    • Field Detail

      • appendable

        public static java.lang.Appendable appendable
        This is an instance of java.lang.Appendable that will accept log text generated from the methods in this class. Following the static API principle does result in one drawback, thus far. This class contains 100% static methods and fields. There are no instantiations or constructed instances of this class. However, since this class has the ability to send text to a terminal (like System.out, for instance); a global, static field (this field) has been created to make it easy for the output from these Operating System commands to printed to the screen, or just about anywhere (using this Appendable).

        ISSUE: Though this global, static 'log' is automatically used for printing by the methods in this class, and although this log may be configured using any Object that implements the interface java.lang.Appendable, this does have one ramification. If multiple java Thread's are making calls to the methods in this class, and the JVM changes the Thread that is running - the output that is sent to the 'log' (if it were being printed to the screen, for instance) might look like it has suddenly 'jumped' from one java.lang.Process to another.

        RETURN-VALUES NOT-AFFECTED: The primary feature to think about is that the values (instances of OSResponse) are all very Thread-safe. Quite a bit of care has been taken to ensure that when invoking an Operating-System level process, there are no potential hangs, locks, or other problems from this multi-threaded method calling. It is only the "general log" that will not look so nice if multiple threads are making calls to the methods in this class at the same time.

        HOW TO SOLVE:

        1. Don't make invocations to this class from different Java Thread's, and expect terminal-output (or wherever the text is sent) to look so nice.
        2. Register a non-printing Appendable to this field, and accept that the output being sent to this log will not look so great if multiple Thread's are writing to this same log at the same time.
        3. If multiple threads need to make O/S calls at the same time, *AND*, you would like to be able to log the text-output that would normally be sent to the screen, use the OSResponse instances returned by the methods to retrieve the Standard Output and Standard-Error text; and send that text to a log of your own devices. The actual return values from the methods in this class are all 100% Thread Safe. (Again, it is just this global log-Appendable field that is not).
        4. Write the String[] array commands without using this class, and make direct invocations to OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT, and control all the output printing in your code.

        This parameter expects an implementation of Java's interface java.lang.Appendable which allows for a wide range of options when logging intermediate messages.
        Class or Interface InstanceUse & Purpose
        'System.out'Sends text to the standard-out terminal
        Torello.Java.StorageWriterSends text to System.out, and saves it, internally.
        FileWriter, PrintWriter, StringWriterGeneral purpose java text-output classes
        FileOutputStream, PrintStreamMore general-purpose java text-output classes

        IMPORTANT: The interface Appendable requires that the check exception IOException must be caught when using its append(CharSequence) methods.
        See Also:
        StorageWriter
        Code:
        Exact Field Declaration Expression:
        1
        public static Appendable appendable = System.out;
        
      • SCT_TEXT_UTF8

        public static final java.lang.String SCT_TEXT_UTF8
        Text-File, Plain, UTF-8. NOTE: May be used for calls to SCT(String s1, String type);
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
        1
        public static final String SCT_TEXT_UTF8 = "text/plain; charset=utf-8";
        
      • SCT_HTML_UTF8

        public static final java.lang.String SCT_HTML_UTF8
        Text-File, HTML, UTF-8. NOTE: May be used for calls to SCT(String s1, String type);
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
        1
        public static final String SCT_HTML_UTF8 = "text/html; charset=utf-8";
        
      • SCT_JAVASCRIPT_UTF8

        public static final java.lang.String SCT_JAVASCRIPT_UTF8
        Text-file, Java-Script, UTF-8. NOTE: This is to be used for calls to SCT(String s1, String type);
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
        1
        public static final String SCT_JAVASCRIPT_UTF8 = "application/javascript; charset=utf-8";
        
      • SCT_JAVASCRIPT

        public static final java.lang.String SCT_JAVASCRIPT
        Text-file, Java-Script. NOTE: This is to be used for calls to SCT(String s1, String type);
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
        1
        public static final String SCT_JAVASCRIPT = "application/javascript";
        
    • Method Detail

      • RM

        public static OSResponse RM​(java.lang.String s,
                                    java.lang.String... switches)
                             throws java.io.IOException
        Calls gsutil with "rm" arguments.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m rm <switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s - The GCS bucket-storage address of files to delete. Can Include wildcards: '*' and '**'
        switches - This may be appended to the command, providing Google's 'gsutil' with switches.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
         String[] cmd = BUILD_COMMAND
             (new String[] { "gsutil", "-m", "rm" }, switches, s, NO_TARGET);
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • RM

        public static OSResponse RM​(java.lang.Iterable<java.lang.String> iterable,
                                    java.lang.String... switches)
                             throws java.io.IOException
        Convenience Method. Invokes RM(String[], String[]).

        Converts Iterable<String> to String[] Array
        Code:
        Exact Method Body:
        1
         return RM(TO_ARRAY(iterable), switches);
        
      • RM

        public static OSResponse RM​(java.lang.String[] sArr,
                                    java.lang.String... switches)
                             throws java.io.IOException
        Calls gsutil with "rm" arguments.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m rm <switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        sArr - The list GCS bucket-storage address of files to delete. Can Include wildcards: '*' and '**'
        switches - This may be appended to the command, providing Google's 'gsutil' with switches.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
         String[] cmd = BUILD_COMMAND
             (new String[] { "gsutil", "-m", "rm" }, switches, sArr, NO_TARGET);
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • MV

        public static OSResponse MV​(java.lang.String source,
                                    java.lang.String target,
                                    java.lang.String... switches)
                             throws java.io.IOException
        Calls gsutil with "mv" arguments.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m mv <switches> <source(s)> <target>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        source - The GCS bucket-storage source-address. Can Include wildcards: '*' and '**'
        target - The GCS bucket-storage target-address.
        switches - This may be appended to the command, providing Google's 'gsutil' with switches.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
         String[] cmd = BUILD_COMMAND
             (new String[] { "gsutil", "-m", "mv" }, switches, source, target);
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • MV

        public static OSResponse MV​(java.lang.Iterable<java.lang.String> sources,
                                    java.lang.String target,
                                    java.lang.String... switches)
                             throws java.io.IOException
        Convenience Method. Invokes MV(String[], String, String[]).

        Converts Iterable<String> to String[] Array
        Code:
        Exact Method Body:
        1
         return MV(TO_ARRAY(sources), target, switches);
        
      • MV

        public static OSResponse MV​(java.lang.String[] sources,
                                    java.lang.String target,
                                    java.lang.String... switches)
                             throws java.io.IOException
        Calls gsutil with "mv" arguments.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m mv <switches> <source(s)> <target>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        sources - A list of arguments that need to be copied, as an array. Can Include wildcards: '*' and '**'
        target - The target/destination address for the list of files to be copied.
        switches - This may be appended to the command, providing Google's 'gsutil' with switches.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
         String[] cmd = BUILD_COMMAND
             (new String[] { "gsutil", "-m", "mv" }, switches, sources, target);
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CP

        public static OSResponse CP​(java.lang.String source,
                                    java.lang.String target,
                                    java.lang.String... switches)
                             throws java.io.IOException
        Calls gsutil with the "cp" argument.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m cp <switches> <source(s)> <target>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        source - The GCS bucket-storage source-address, or local BASH shell source-address. Can Include wildcards: '*' and '**'
        target - The GCS bucket-storage target-address, or local BASH shell target-address.
        switches - This may be appended to the command, providing Google's 'gsutil' with switches.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
         String[] cmd = BUILD_COMMAND
             (new String[] { "gsutil", "-m", "cp" }, switches, source, target);
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CP

        public static OSResponse CP​(java.lang.Iterable<java.lang.String> sources,
                                    java.lang.String target,
                                    java.lang.String... switches)
                             throws java.io.IOException
        Convenience Method. Invokes CP(String[], String, String[]).

        Converts Iterable<String> to String[] Array
        Code:
        Exact Method Body:
        1
         return CP(TO_ARRAY(sources), target, switches);
        
      • CP

        public static OSResponse CP​(java.lang.String[] sources,
                                    java.lang.String target,
                                    java.lang.String... switches)
                             throws java.io.IOException
        Calls gsutil with the "cp" argument.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m cp <switches> <source(s)> <target>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        sources - A list of arguments that need to be copied, as an array. Can Include wildcards: '*' and '**'
        target - The target/destination address for the list of files to be copied.
        switches - This may be appended to the command, providing Google's 'gsutil' with switches.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
         String[] cmd = BUILD_COMMAND
             (new String[] { "gsutil", "-m", "cp" }, switches, sources, target);
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • RSYNC

        public static OSResponse RSYNC​(java.lang.String sources,
                                       java.lang.String target,
                                       java.lang.String... switches)
                                throws java.io.IOException
        Calls gsutil with arguments: "-m rsync ...". This method synchronizes a local directory with the directory in a Google Cloud Storage Bucket.

        NOTE: 'rsync' crashed my whole cloud-shell... Use at your discretion. The command was properly formed, to the best of my knowledge. It complained of 'egress' for quite a few days after using gsutil with the 'rsync' option.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m rsync <switches> <source(s)> <target>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        sources - The source-address.
        target - The target-address.
        switches - This may be appended to the command, providing Google's 'gsutil' with switches.

        '-d' : This will inform GSUTIL to remove files that are not found in the users directory, but are sitting on the Storage Bucket Server Location - in the corresponding / same directory

        '-r' : This will cause the sync to run recursively.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
         String[] cmd = BUILD_COMMAND
             (new String[] { "gsutil", "-m", "rsync" }, switches, sources, target);
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • MP

        public static OSResponse MP​(java.lang.String s1,
                                    java.lang.String... extraSwitches)
                             throws java.io.IOException
        MP stands for "Make Public" - and this method is used to force the target file or files on Google Cloud Server to become "visible" to the public. It updates the Access Control List.

        SPECIFICALLY: It grants read access to the public / "AllUsers". This is the most-common means I have found for allowing the Google-Web-Server to serve up files from a Google Cloud Storage Bucket. Remember, this only works if you have registered your bucket with a domain-name server. This is usually around $12 per year.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m acl ch -u AllUsers:R <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1 - The GCS bucket file or directory address. Note '*' or '**' may be used here.
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the public-visibility of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "acl", "ch", "-u", "AllUsers:R" },
             extraSwitches, s1, NO_TARGET
         );
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • MP

        public static OSResponse MP​(java.lang.Iterable<java.lang.String> iterable,
                                    java.lang.String... extraSwitches)
                             throws java.io.IOException
        Convenience Method. Invokes MP(String[], String[]).

        Converts Iterable<String> to String[] Array
        Code:
        Exact Method Body:
        1
         return MP(TO_ARRAY(iterable), extraSwitches);
        
      • MP

        public static OSResponse MP​(java.lang.String[] sArr,
                                    java.lang.String... extraSwitches)
                             throws java.io.IOException
        MP stands for "Make Public" - and this method is used to force the target file or files on Google Cloud Server to become "visible" to the public. It updates the Access Control List.

        SPECIFICALLY: It grants read access to the public / "AllUsers". This is the most-common means I have found for allowing the Google-Web-Server to serve up files from a Google Cloud Storage Bucket. Remember, this only works if you have registered your bucket with a domain-name server. This is usually around $12 per year.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m acl ch -u AllUsers:R <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        sArr - The GCS bucket file or directory addresses. Note '*' or '**' may be used here.
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the public-visibility of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "acl", "ch", "-u", "AllUsers:R" },
             extraSwitches, sArr, NO_TARGET
         );
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • SP

        public static OSResponse SP​(java.lang.String s1,
                                    java.lang.String... extraSwitches)
                             throws java.io.IOException
        SP stands for "Stop Public" - and this method is used to force the target file or files on Google Cloud Server to become "invisible" to the public. It updates the Access Control List.

        SPECIFICALLY: It revokes read access to the public / "AllUsers".

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m acl ch -d AllUsers <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1 - The GCS bucket file or directory address. Note '*' or '**' may be used here.
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to stop the public-visibility of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "acl", "ch", "-d", "AllUsers" },
             extraSwitches, s1, NO_TARGET
         );
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • SP

        public static OSResponse SP​(java.lang.Iterable<java.lang.String> iterable,
                                    java.lang.String... extraSwitches)
                             throws java.io.IOException
        Convenience Method. Invokes SP(String[], String[]).

        Converts Iterable<String> to String[] Array
        Code:
        Exact Method Body:
        1
         return SP(TO_ARRAY(iterable), extraSwitches);
        
      • SP

        public static OSResponse SP​(java.lang.String[] sArr,
                                    java.lang.String... extraSwitches)
                             throws java.io.IOException
        SP stands for "Stop Public" - and this method is used to force the target file or files on Google Cloud Server to become "invisible" to the public. It updates the Access Control List.

        SPECIFICALLY: It revokes read access to the public / "AllUsers".

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m acl ch -d AllUsers <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        sArr - The GCS bucket file or directory address. Note '*' or '**' may be used here.
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to stop the public-visibility of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "acl", "ch", "-d", "AllUsers" },
             extraSwitches, sArr, NO_TARGET
         );
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • SMA

        public static OSResponse SMA​(java.lang.String s1,
                                     int seconds,
                                     java.lang.String... extraSwitches)
                              throws java.io.IOException
        SMA is short of "Set Max Age." This handles the problem of browsers that cache stale output data. When the "max-age" meta-tag is set to zero, your browser will always poll the Google Cloud Server for new page-information, rather than relying on cached pages. This method is extremely helpful if you are debugging and changing web-content while hosting a web-site domain using GCS Storage Buckets.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h "Cache-Control:public, max-age=<seconds>" <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1 - The GCS bucket-storage address. gs://bucket-name/directoryname/filename
        NOTE: "filename" may contain the asterisks '*' or anything that would normally be passed to gsutil on the shell command-line.
        seconds - This parameter is added to the end of the max-age= string in the cmdSMA argument list. It represents the number of seconds a browser is allowed to cache a page.
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the max-age of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", ("Cache-Control:public, max-age=" + seconds + "") },
             extraSwitches, s1, NO_TARGET
         );
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • SMA

        public static OSResponse SMA​
                    (java.lang.Iterable<java.lang.String> iterable,
                     int seconds,
                     java.lang.String... extraSwitches)
                throws java.io.IOException
        
        Convenience Method. Invokes SMA(String[], int, String[]).

        Converts Iterable<String> to String[] Array
        Code:
        Exact Method Body:
        1
         return SMA(TO_ARRAY(iterable), seconds, extraSwitches);
        
      • SMA

        public static OSResponse SMA​(java.lang.String[] s1Arr,
                                     int seconds,
                                     java.lang.String... extraSwitches)
                              throws java.io.IOException
        SMA is short of "Set Max Age." This handles the problem of browsers that cache stale output data. When the "max-age" meta-tag is set to zero, your browser will always poll the Google Cloud Server for new page-information, rather than relying on cached pages. This method is extremely helpful if you are debugging and changing web-content while hosting a web-site domain using GCS Storage Buckets.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h "Cache-Control:public, max-age=<seconds>" <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        seconds - This parameter is added to the end of the max-age= string in the cmdSMA argument list. It represents the number of seconds a browser is allowed to cache a page.
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the max-age of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", ("Cache-Control:public, max-age=" + seconds + "") },
             extraSwitches, s1Arr, NO_TARGET
         );
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CONTENT_TYPE

        public static OSResponse CONTENT_TYPE​(java.lang.String source,
                                              java.lang.String type,
                                              java.lang.String... extraSwitches)
                                       throws java.io.IOException
        Whenever programming involves foreign-languages or UTF-8, this can be a meta-tag (or web-server setting) that has to be set. It is not mandatory to set this meta-tag with Google-Cloud-Server when working with higher-order UTF-8 character-data, because the meta-information can be placed inside the HTML page itself. However, this is an "alternative-option" to putting meta-information inside your server pages header-sections.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h "Content-Type: <type>" <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        NOTE: Most often, I use this command to set files to "UTF-8" and not Plain-Old ASCII (like here):
        "Content-Type: text/plain; charset=utf-8"
        Parameters:
        source - This is the parameter is supposed to be a file, directory, or expression sequence.
        NOTE: The 'source(s)' may contain the asterisks '*' or anything that would normally be passed to gsutil on the shell command-line.
        type - This is any 'String' that may be used with Google Cloud Server. Must pertain to "Content-Type". There are several pre-defined content-type strings defined in this class that make reasonable values for this parameter.
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the content-type of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        See Also:
        SCT_TEXT_UTF8, SCT_HTML_UTF8, SCT_JAVASCRIPT
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Type: " + type },
             extraSwitches, source, NO_TARGET
         );
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CONTENT_TYPE

        public static OSResponse CONTENT_TYPE​
                    (java.lang.Iterable<java.lang.String> iterable,
                     java.lang.String type,
                     java.lang.String... extraSwitches)
                throws java.io.IOException
        
        Convenience Method. Invokes CONTENT_TYPE(String[], String, String[]).

        Converts Iterable<String> to String[] Array
        Code:
        Exact Method Body:
        1
         return CONTENT_TYPE(TO_ARRAY(iterable), type, extraSwitches);
        
      • CONTENT_TYPE

        public static OSResponse CONTENT_TYPE​(java.lang.String[] s1Arr,
                                              java.lang.String type,
                                              java.lang.String... extraSwitches)
                                       throws java.io.IOException
        Whenever programming involves foreign-languages or UTF-8, this can be a meta-tag (or web-server setting) that has to be set. It is not mandatory to set this meta-tag with Google-Cloud-Server when working with higher-order UTF-8 character-data, because the meta-information can be placed inside the HTML page itself. However, this is an "alternative-option" to putting meta-information inside your server pages header-sections.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h "Content-Type: <type>" <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        NOTE: Most often, I use this command to set files to "UTF-8" and not Plain-Old ASCII (like here):
        "Content-Type: text/plain; charset=utf-8"
        Parameters:
        s1Arr - The GCS bucket-storage address list. gs://bucket-name/directoryname/filename
        NOTE: The 'source(s)' may contain the asterisks '*' or anything that would normally be passed to gsutil on the shell command-line.
        type - This is any 'String' that may be used with Google Cloud Server. Must pertain to "Content-Type". There are several pre-defined content-type strings defined in this class that make reasonable values for this parameter.
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the content-type of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        See Also:
        SCT_TEXT_UTF8, SCT_HTML_UTF8, SCT_JAVASCRIPT
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Type: " + type },
             extraSwitches, s1Arr, NO_TARGET
         );
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CACHE_CONTROL

        public static OSResponse CACHE_CONTROL​(java.lang.String s1,
                                               java.lang.String cacheControlTags,
                                               java.lang.String... extraSwitches)
                                        throws java.io.IOException
        Cache-Control is an HTTP setting, much like Content-Type. This HTTP-Handshake setting informs a web-browser what the rules need to be as far as caching web-pages. Some web-pages have extremely static-content that will never change, and when a browser caches this content, there will be no loss of information to the end-user. Other-times web-pages are returned from live-data-feeds that change the content of the page often. This method here is a more generalized version of the method above named public static void SMA(...) - which stands for 'set max age'. Setting the max-age allows a web-programmer to specify that certain files should not be cached by the web-browser.

        AS AN ASIDE: A very large head-ache in the development process with Google Cloud Server Storage Buckets is remembering to set the "Max-Age" to ZERO, to guarantee that after each iteration of coding or developing, when HTML files are updated and replaced, the browser being used to look at the HTML does not cache the previous iteration/data results.

        The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include: Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h "Cache-Control: <cacheControlTags>" <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1 - This is the parameter is supposed to be a file, directory, or expression sequence
        NOTE: The 'source(s)' may contain the asterisks '*' or anything that would normally be passed to gsutil on the shell command-line.
        cacheControlTags - This is any 'String' that may be used with Google Cloud Server. Must pertain to "Cache-Control"
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the cache-control of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", "Cache-Control: " + cacheControlTags },
             extraSwitches, s1, NO_TARGET
         );
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CACHE_CONTROL

        public static OSResponse CACHE_CONTROL​
                    (java.lang.Iterable<java.lang.String> iterable,
                     java.lang.String cacheControlTags,
                     java.lang.String... extraSwitches)
                throws java.io.IOException
        
        Convenience Method. Invokes CACHE_CONTROL(String[], String, String[])

        Converts Iterable<String> to String[] Array.
        Code:
        Exact Method Body:
        1
         return CACHE_CONTROL(TO_ARRAY(iterable), cacheControlTags, extraSwitches);
        
      • CACHE_CONTROL

        public static OSResponse CACHE_CONTROL​(java.lang.String[] s1Arr,
                                               java.lang.String cacheControlTags,
                                               java.lang.String... extraSwitches)
                                        throws java.io.IOException
        Cache-Control is an HTTP setting, much like Content-Type. This HTTP-Handshake setting informs a web-browser what the rules need to be as far as caching web-pages. Some web-pages have extremely static-content that will never change, and when a browser caches this content, there will be no loss of information to the end-user. Other-times web-pages are returned from live-data-feeds that change the content of the page often. This method here is a more generalized version of the method above named public static void SMA(...) - which stands for 'set max age'. Setting the max-age allows a web-programmer to specify that certain files should not be cached by the web-browser.

        AS AN ASIDE: A very large head-ache in the development process with Google Cloud Server Storage Buckets is remembering to set the "Max-Age" to ZERO, to guarantee that after each iteration of coding or developing, when HTML files are updated and replaced, the browser being used to look at the HTML does not cache the previous iteration/data results.

        The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include: Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h "Cache-Control: <cacheControlTags>" <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1Arr - This is the parameter is supposed to be a file, directory, or expression sequence.
        NOTE: The 'source(s)' may contain the asterisks '*' or anything that would normally be passed to gsutil on the shell command-line.
        cacheControlTags - This is any 'String' that may be used with Google Cloud Server. Must pertain to "Cache-Control"
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the cache-control of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
        6
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", "Cache-Control: " + cacheControlTags },
             extraSwitches, s1Arr, NO_TARGET
         );
        
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CONTENT_ENCODING

        public static OSResponse CONTENT_ENCODING​
                    (java.lang.String s1,
                     java.lang.String contentEncodingTags,
                     java.lang.String... extraSwitches)
                throws java.io.IOException
        
        Content-Encoding is an HTTP setting, much like Content-Type, but for the purposes of News-Scraping and other Internet Publishing, it has not been used much, if at all, during the development of these packages.

        The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include: Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h "Content-Encoding: <contentEncodingTags>" <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1 - This is the parameter is supposed to be a file, directory, or expression sequence
        NOTE: The 'source(s)' may contain the asterisks '*' or anything that would normally be passed to gsutil on the shell command-line.
        contentEncodingTags - This is any 'String' that may be used with Google Cloud Server. Must pertain to "Content-Encoding"
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the content-encoding of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
        6
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Encoding: " + contentEncodingTags },
             extraSwitches, s1, NO_TARGET
         );
        
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CONTENT_ENCODING

        public static OSResponse CONTENT_ENCODING​
                    (java.lang.String[] s1Arr,
                     java.lang.String contentEncodingTags,
                     java.lang.String... extraSwitches)
                throws java.io.IOException
        
        Content-Encoding is an HTTP setting, much like Content-Type, but for the purposes of News-Scraping and other Internet Publishing, it has not been used much, if at all, during the development of these packages.

        The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include: Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h "Content-Encoding: <contentEncodingTags>" <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1Arr - This is the parameter is supposed to be a file, directory, or expression sequence.
        NOTE: The 'source(s)' may contain the asterisks '*' or anything that would normally be passed to gsutil on the shell command-line.
        contentEncodingTags - This is any 'String' that may be used with Google Cloud Server. Must pertain to "Content-Encoding"
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the content-encoding of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
        6
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Encoding: " + contentEncodingTags },
             extraSwitches, s1Arr, NO_TARGET
         );
        
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CONTENT_ENCODING

        public static OSResponse CONTENT_ENCODING​
                    (java.lang.Iterable<java.lang.String> iterable,
                     java.lang.String contentEncodingTags,
                     java.lang.String... extraSwitches)
                throws java.io.IOException
        
        Convenience Method. Invokes CONTENT_ENCODING(String[], String, String[]).

        Converts Iterable<String> to String[] Array
        Code:
        Exact Method Body:
        1
         return CONTENT_ENCODING(TO_ARRAY(iterable), contentEncodingTags, extraSwitches);
        
      • CONTENT_DISPOSITION

        public static OSResponse CONTENT_DISPOSITION​
                    (java.lang.String s1,
                     java.lang.String contentDispositionTags,
                     java.lang.String... extraSwitches)
                throws java.io.IOException
        
        Content-Disposition is an HTTP setting, much like Content-Type, but for the purposes of News-Scraping and other Internet Publishing, it has not been used much, if at all, during the development of these packages.

        The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include: Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h "Content-Disposition: <contentDispositionTags>" <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1 - This is the parameter is supposed to be a file, directory, or expression sequence
        NOTE: The 'source(s)' may contain the asterisks '*' or anything that would normally be passed to gsutil on the shell command-line.
        contentDispositionTags - This is any 'String' that may be used with Google Cloud Server. Must pertain to "Content-Disposition"
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the content-disposition of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
        6
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Disposition: " + contentDispositionTags },
             extraSwitches, s1, NO_TARGET
         );
        
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CONTENT_DISPOSITION

        public static OSResponse CONTENT_DISPOSITION​
                    (java.lang.Iterable<java.lang.String> iterable,
                     java.lang.String contentDispositionTags,
                     java.lang.String... extraSwitches)
                throws java.io.IOException
        
        Convenience Method. Invokes CONTENT_DISPOSITION(String[], String, String[]).

        Converts Iterable<String> to String[] Array
        Code:
        Exact Method Body:
        1
         return CONTENT_DISPOSITION(TO_ARRAY(iterable), contentDispositionTags, extraSwitches);
        
      • CONTENT_DISPOSITION

        public static OSResponse CONTENT_DISPOSITION​
                    (java.lang.String[] s1Arr,
                     java.lang.String contentDispositionTags,
                     java.lang.String... extraSwitches)
                throws java.io.IOException
        
        Content-Disposition is an HTTP setting, much like Content-Type, but for the purposes of News-Scraping and other Internet Publishing, it has not been used much, if at all, during the development of these packages.

        The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include: Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h "Content-Disposition: <contentDispositionTags>" <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1Arr - This is the parameter is supposed to be a file, directory, or expression sequence.
        NOTE: The 'source(s)' may contain the asterisks '*' or anything that would normally be passed to gsutil on the shell command-line.
        contentDispositionTags - This is any 'String' that may be used with Google Cloud Server. Must pertain to "Content-Disposition"
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the content-disposition of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
        6
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Disposition: " + contentDispositionTags },
             extraSwitches, s1Arr, NO_TARGET
         );
        
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CUSTOM_METADATA

        public static OSResponse CUSTOM_METADATA​(java.lang.String s1,
                                                 java.lang.String metaTag,
                                                 java.lang.String... extraSwitches)
                                          throws java.io.IOException
        This just allows you to set custom HTTP-Header tags. When reviewing the Google Cloud Server Documentation Pages for 'GSUTIL' they provide this example of a "Custom Meta HTTP Tag." The following text-and-example are directly copied from:

        https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata

        All fields and their values must consist only of ASCII characters, with the exception of values for x-goog-meta- fields, which may contain arbitrary Unicode values. Note that when setting metadata using the XML API, which sends custom metadata as HTTP headers, Unicode characters will be encoded using UTF-8, then url-encoded to ASCII. For example:


        UNIX or DOS Shell Command:
        gsutil setmeta -h "x-goog-meta-foo: ã" gs://bucket/object

        would store the custom metadata key-value pair of "foo" and "%C3%A3". Subsequently, running "ls -L" using the JSON API to list the object's metadata would print "%C3%A3", while "ls -L" using the XML API would url-decode this value automatically, printing the character "ã".


        The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include: Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h <metaTag> <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, whenever multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1 - This is the parameter is supposed to be a file, directory, or expression sequence
        NOTE: The 'source(s)' may contain the asterisks '*' or anything that would normally be passed to gsutil on the shell command-line.
        metaTag - This is any 'String' that may be used with Google Cloud Server's 'setmeta' parameter for gsutil.
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the meta-information of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
        6
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", metaTag },
             extraSwitches, s1, NO_TARGET
         );
        
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • CUSTOM_METADATA

        public static OSResponse CUSTOM_METADATA​
                    (java.lang.Iterable<java.lang.String> iterable,
                     java.lang.String tags,
                     java.lang.String... extraSwitches)
                throws java.io.IOException
        
        Convenience Method. Invokes CUSTOM_METADATA(String[], String, String[]).

        Converts Iterable<String> to String[] Array
        Code:
        Exact Method Body:
        1
         return CUSTOM_METADATA(TO_ARRAY(iterable), tags, extraSwitches);
        
      • CUSTOM_METADATA

        public static OSResponse CUSTOM_METADATA​(java.lang.String[] s1Arr,
                                                 java.lang.String metaTag,
                                                 java.lang.String... extraSwitches)
                                          throws java.io.IOException
        This just allows you to set custom HTTP-Header tags. When reviewing the Google Cloud Server Documentation Pages for 'GSUTIL' they provide this example of a "Custom Meta HTTP Tag." The following text-and-example are directly copied from:

        https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata

        All fields and their values must consist only of ASCII characters, with the exception of values for x-goog-meta- fields, which may contain arbitrary Unicode values. Note that when setting metadata using the XML API, which sends custom metadata as HTTP headers, Unicode characters will be encoded using UTF-8, then url-encoded to ASCII. For example:


        UNIX or DOS Shell Command:
        gsutil setmeta -h "x-goog-meta-foo: ã" gs://bucket/object

        would store the custom metadata key-value pair of "foo" and "%C3%A3". Subsequently, running "ls -L" using the JSON API to list the object's metadata would print "%C3%A3", while "ls -L" using the XML API would url-decode this value automatically, printing the character "ã".


        The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include: Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil -m setmeta -h <metaTag> <extra-switches> <source(s)>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, whenever multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1Arr - This is the parameter is supposed to be a file, directory, or expression sequence.
        NOTE: The 'source(s)' may contain the asterisks '*' or anything that would normally be passed to gsutil on the shell command-line.
        metaTag - This is any 'String' that may be used with Google Cloud Server's 'setmeta' parameter for gsutil.
        extraSwitches - This may be appended to the command, providing Google's 'gsutil' with switches. The salient arguments to set the meta-information of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
        6
         String[] cmd = BUILD_COMMAND(
             new String[] { "gsutil", "-m", "setmeta", "-h", metaTag },
             extraSwitches, s1Arr, NO_TARGET
         );
        
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);
        
      • LS

        public static OSResponse LS​(java.lang.String s1,
                                    java.lang.String... switches)
                             throws java.io.IOException
        Lists the contents of a directory in a Google Cloud Storage Bucket.

        Google Cloud Shell Equivalent:

        user@cloudshell:~ (project-ID)$ gsutil ls <fileOrDir>

        Google Note: Google expects that when multiple files or directories are processed, that a '-m' flag is passed to the command to increase efficiency. Therefore, whenever multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
        Parameters:
        s1 - The GCS storage file or directory. Note: '*' or '**' may be used.
        Returns:
        Returns an instance of OSResponse. This response-Object (data-record) class holds three public, final fields:
        Process response-code
        Text sent to Standard-Output (as a java.lang.String)
        Text sent to Error-Output (also as a String)

        This OSResponse instance may be discarded without any effect on Process Execution. It is only provided as a convenience in case more information is required about the results of the O/S command invocation.

        Process Status: Upon completion of this method, the Operating-System java.lang.Process is guaranteed to have run to completion.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
        1
        2
         String[] cmd = BUILD_COMMAND(new String[] { "gsutil", "ls" }, switches, s1, NO_TARGET);
         return OSResponse.PRINT_CMD_RUN_CMD_PRINT_OUTPUT(cmd, appendable);