GCSFileDownloader
public
class
GCSFileDownloader
extends GCSFileDownloaderBase
implements
IFileDownloader
| java.lang.Object | |||
| ↳ | com.android.tradefed.util.gcs.GCSCommon | ||
| ↳ | com.android.tradefed.util.gcs.GCSFileDownloaderBase | ||
| ↳ | com.android.tradefed.util.GCSFileDownloader | ||
用于从 Google Cloud Storage (GCS) 下载文件的文件下载器。
摘要
公共构造函数 | |
|---|---|
GCSFileDownloader()
|
|
GCSFileDownloader(Boolean createEmptyFile)
|
|
GCSFileDownloader(File jsonKeyFile)
|
|
GCSFileDownloader(File jsonKeyFile, Boolean createEmptyFile)
|
|
公共方法 | |
|---|---|
static
File
|
createTempFileForRemote(String remoteFilePath, File rootDir)
|
void
|
downloadFile(String remotePath, File destFile)
|
File
|
downloadFile(String remoteFilePath)
从 GCS 下载文件。 |
boolean
|
isFresh(File localFile, String remotePath)
检查本地文件的新鲜度。 |
受保护的方法 | |
|---|---|
void
|
clearCache()
|
void
|
downloadFile(String bucketName, String remoteFilename, File localFile)
|
Storage
|
getStorage(
替换了基准中的实现,以支持基于 TF 选项的凭据。 |
String[]
|
parseGcsPath(String remotePath)
|
公共构造函数
GCSFileDownloader
public GCSFileDownloader ()
GCSFileDownloader
public GCSFileDownloader (Boolean createEmptyFile)
| 参数 | |
|---|---|
createEmptyFile |
Boolean |
GCSFileDownloader
public GCSFileDownloader (File jsonKeyFile)
| 参数 | |
|---|---|
jsonKeyFile |
File |
GCSFileDownloader
public GCSFileDownloader (File jsonKeyFile,
Boolean createEmptyFile)| 参数 | |
|---|---|
jsonKeyFile |
File |
createEmptyFile |
Boolean |
公共方法
createTempFileForRemote
public static File createTempFileForRemote (String remoteFilePath,
File rootDir)| 参数 | |
|---|---|
remoteFilePath |
String |
rootDir |
File |
| 返回 | |
|---|---|
File |
|
| 抛出 | |
|---|---|
BuildRetrievalError |
|
downloadFile
public void downloadFile (String remotePath,
File destFile)| 参数 | |
|---|---|
remotePath |
String |
destFile |
File |
| 抛出 | |
|---|---|
BuildRetrievalError |
|
downloadFile
public File downloadFile (String remoteFilePath)
从 GCS 下载文件。
目前仅支持 GCS 路径。
| 参数 | |
|---|---|
remoteFilePath |
String:采用 gs://bucket/file/path 格式的 GCS 路径。 |
| 返回 | |
|---|---|
File |
本地文件 |
| 抛出 | |
|---|---|
|
com.android.tradefed.build.BuildRetrievalError |
BuildRetrievalError |
|
isFresh
public boolean isFresh (File localFile,
String remotePath)检查本地文件的新鲜度。如果本地文件与远程文件相同,则表示本地文件是最新的。否则,本地文件已过时。这主要用于缓存。默认实现始终会返回 true,因此如果文件是不可变的,则永远无需检查新鲜度。
| 参数 | |
|---|---|
localFile |
File:本地文件。 |
remotePath |
String:远程文件路径。 |
| 返回 | |
|---|---|
boolean |
如果本地文件是新鲜的,则返回 true,否则返回 false。 |
| 抛出 | |
|---|---|
BuildRetrievalError |
|
受保护的方法
clearCache
protected void clearCache ()
downloadFile
protected void downloadFile (String bucketName,
String remoteFilename,
File localFile)| 参数 | |
|---|---|
bucketName |
String |
remoteFilename |
String |
localFile |
File |
| 抛出 | |
|---|---|
BuildRetrievalError |
|
getStorage
protected Storage getStorage (scopes)
替换了基准中的实现,以支持基于 TF 选项的凭据。
| 参数 | |
|---|---|
scopes |
:要为其请求凭据的特定范围。 |
| 返回 | |
|---|---|
Storage |
GCS 存储分区的 Storage 对象 |
| 抛出 | |
|---|---|
|
IOException |
parseGcsPath
protected String[] parseGcsPath (String remotePath)
| 参数 | |
|---|---|
remotePath |
String |
| 返回 | |
|---|---|
String[] |
|
| 抛出 | |
|---|---|
BuildRetrievalError |
|