GCSFileDownloader
public
class
GCSFileDownloader
extends GCSFileDownloaderBase
implements
IFileDownloader
File downloader to download file from google cloud storage (GCS).
Summary
Public methods |
static
File
|
createTempFileForRemote(String remoteFilePath, File rootDir)
|
void
|
downloadFile(String remotePath, File destFile)
|
File
|
downloadFile(String remoteFilePath)
Download file from GCS.
|
boolean
|
isFresh(File localFile, String remotePath)
Check local file's freshness.
|
Protected methods |
void
|
clearCache()
|
void
|
downloadFile(String bucketName, String remoteFilename, File localFile)
|
Storage
|
getStorage( scopes)
Override the implementation in base to support credential based on TF options.
|
String[]
|
parseGcsPath(String remotePath)
|
Public constructors
GCSFileDownloader
public GCSFileDownloader ()
GCSFileDownloader
public GCSFileDownloader (Boolean createEmptyFile)
Parameters |
createEmptyFile |
Boolean |
GCSFileDownloader
public GCSFileDownloader (File jsonKeyFile)
Parameters |
jsonKeyFile |
File |
Public methods
createTempFileForRemote
public static File createTempFileForRemote (String remoteFilePath,
File rootDir)
Parameters |
remoteFilePath |
String |
rootDir |
File |
downloadFile
public void downloadFile (String remotePath,
File destFile)
Parameters |
remotePath |
String |
destFile |
File |
downloadFile
public File downloadFile (String remoteFilePath)
Download file from GCS.
Right now only support GCS path.
Parameters |
remoteFilePath |
String : gs://bucket/file/path format GCS path. |
isFresh
public boolean isFresh (File localFile,
String remotePath)
Check local file's freshness. If local file is the same as remote file, then it's fresh. If
not, local file is stale. This is mainly used for cache. The default implementation will
always return true, so if the file is immutable it will never need to check freshness.
Parameters |
localFile |
File : local file. |
remotePath |
String : remote file path. |
Returns |
boolean |
True if local file is fresh, otherwise false. |
Protected methods
clearCache
protected void clearCache ()
downloadFile
protected void downloadFile (String bucketName,
String remoteFilename,
File localFile)
Parameters |
bucketName |
String |
remoteFilename |
String |
localFile |
File |
getStorage
protected Storage getStorage ( scopes)
Override the implementation in base to support credential based on TF options.
Parameters |
scopes |
: specific scopes to request credential for. |
Returns |
Storage |
Storage object of the GCS bucket |
parseGcsPath
protected String[] parseGcsPath (String remotePath)
Parameters |
remotePath |
String |