Stay organized with collections
Save and categorize content based on your preferences.
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)
Download a file from a GCS bucket file.
|
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 (Boolean createEmptyFile)
Parameters |
createEmptyFile |
Boolean |
GCSFileDownloader
public GCSFileDownloader ()
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)
Download a file from a GCS bucket file.
Parameters |
remotePath |
String : GCS bucket name |
destFile |
File : the filename |
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 |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-08-13 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-08-13 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-13 UTC."]]