Package tilda.utils.gcp
Class CSHelper
- java.lang.Object
-
- tilda.utils.gcp.CSHelper
-
public class CSHelper extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.logging.log4j.Logger
LOG
-
Constructor Summary
Constructors Constructor Description CSHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
downloadBlobsToLocalStorage(com.google.cloud.storage.Storage cs, java.lang.String bucketName, java.util.List<java.lang.String> allBlobs, java.lang.String localDestPath, boolean override)
static java.util.List<java.lang.String>
getObjectsinRemoteFolder(com.google.cloud.storage.Storage cs, java.lang.String bucketName, java.lang.String dir)
static long
getRemoteFolderSize(com.google.cloud.storage.Storage cs, java.lang.String bucketName, java.util.List<java.lang.String> allObjects)
static com.google.cloud.storage.Storage
getStorage(java.lang.String dataProjectName)
Given the environment variable name passed in (default isFileUtil._DEFAULT_ENV_VAR_NAME
), looks up the value which points to a path, and then based on the project name, lookup the file "[SERVICE_ACCOUNTS_CREDENTIALS_PATH]/.xxx.key.cs.json". static com.google.cloud.storage.Storage
getStorage(java.lang.String envVariable, java.lang.String dataProjectName)
static java.util.List<java.lang.String>
getSubDirectories(com.google.cloud.storage.Storage cs, java.lang.String bucketName, java.lang.String dir)
-
-
-
Method Detail
-
getStorage
public static com.google.cloud.storage.Storage getStorage(java.lang.String dataProjectName) throws java.io.FileNotFoundException, java.io.IOException
Given the environment variable name passed in (default isFileUtil._DEFAULT_ENV_VAR_NAME
), looks up the value which points to a path, and then based on the project name, lookup the file "[SERVICE_ACCOUNTS_CREDENTIALS_PATH]/.xxx.key.cs.json". 'xxx' can be anything (and is optional) but is generally the first few characters of the original key file. This is done so different keys to the same project could be used in a team while keeping file names specific to the actual key file generated by GCP. - Parameters:
dataProjectName
-- Returns:
- An authenticated capsico-store Storage instance
- Throws:
java.io.FileNotFoundException
java.io.IOException
-
getStorage
public static com.google.cloud.storage.Storage getStorage(java.lang.String envVariable, java.lang.String dataProjectName) throws java.io.FileNotFoundException, java.io.IOException
- Throws:
java.io.FileNotFoundException
java.io.IOException
-
getSubDirectories
public static java.util.List<java.lang.String> getSubDirectories(com.google.cloud.storage.Storage cs, java.lang.String bucketName, java.lang.String dir)
-
getObjectsinRemoteFolder
public static java.util.List<java.lang.String> getObjectsinRemoteFolder(com.google.cloud.storage.Storage cs, java.lang.String bucketName, java.lang.String dir)
-
getRemoteFolderSize
public static long getRemoteFolderSize(com.google.cloud.storage.Storage cs, java.lang.String bucketName, java.util.List<java.lang.String> allObjects) throws java.io.IOException
- Throws:
java.io.IOException
-
downloadBlobsToLocalStorage
public static void downloadBlobsToLocalStorage(com.google.cloud.storage.Storage cs, java.lang.String bucketName, java.util.List<java.lang.String> allBlobs, java.lang.String localDestPath, boolean override) throws java.io.IOException
- Throws:
java.io.IOException
-
-