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(File jsonKeyFile)
GCSFileDownloader(File jsonKeyFile, Boolean createEmptyFile)
GCSFileDownloader(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(Collection<String> scopes)

覆寫基本實作項目,以支援根據 TF 選項的憑證。

String[] parseGcsPath(String remotePath)

公用建構函式

GCSFileDownloader

public GCSFileDownloader ()

GCSFileDownloader

public GCSFileDownloader (File jsonKeyFile)

參數
jsonKeyFile File

GCSFileDownloader

public GCSFileDownloader (File jsonKeyFile, 
                Boolean createEmptyFile)

參數
jsonKeyFile File

createEmptyFile Boolean

GCSFileDownloader

public GCSFileDownloader (Boolean createEmptyFile)

參數
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 (Collection<String> scopes)

覆寫基礎中的實作項目,以支援根據 TF 選項的憑證。

參數
scopes Collection:要求憑證的特定範圍。

傳回
Storage GCS bucket 的 Storage 物件

擲回
java.io.IOException
IOException

parseGcsPath

protected String[] parseGcsPath (String remotePath)

參數
remotePath String

傳回
String[]

擲回
BuildRetrievalError