GCS檔案下載器
public class GCSFileDownloader
extends GCSCommon
implements IFileDownloader
java.lang.Object | ||
↳ | com.android.tradefed.util.GCSCommon | |
↳ | com.android.tradefed.util.GCSFileDownloader |
文件下載器用於從谷歌雲端儲存(GCS)下載檔案。
概括
領域 | |
---|---|
public static final String | GCS_APPROX_PREFIX |
public static final String | GCS_PREFIX
|
公共構造函數 | |
---|---|
GCSFileDownloader (File jsonKeyFile) | |
GCSFileDownloader () |
公共方法 | |
---|---|
static File | createTempFileForRemote (String remoteFilePath, File rootDir) 在臨時磁碟上建立一個唯一的檔案來存放具有給定路徑的下載檔案。 |
InputStream | downloadFile (String bucketName, String filename) 從 GCS 儲存桶檔案下載檔案。 |
void | downloadFile (String remotePath, File destFile) |
File | downloadFile (String remoteFilePath) 從 GCS 下載檔案。 |
boolean | isFresh (File localFile, String remotePath) 檢查本地文件的新鮮度。 |
受保護的方法 | |
---|---|
void | clearCache () |
領域
GCS_APPROX_PREFIX
public static final String GCS_APPROX_PREFIX
GCS_前綴
public static final String GCS_PREFIX
公共構造函數
GCS檔案下載器
public GCSFileDownloader (File jsonKeyFile)
參數 | |
---|---|
jsonKeyFile | File |
GCS檔案下載器
public GCSFileDownloader ()
公共方法
為遠端建立暫存文件
public static File createTempFileForRemote (String remoteFilePath, File rootDir)
在臨時磁碟上建立一個唯一的檔案來存放具有給定路徑的下載檔案。
根據路徑中的基本檔名構造檔名
參數 | |
---|---|
remoteFilePath | String :建構名稱的遠端路徑 |
rootDir | File |
退貨 | |
---|---|
File |
投擲 | |
---|---|
BuildRetrievalError |
下載文件
public InputStream downloadFile (String bucketName, String filename)
從 GCS 儲存桶檔案下載檔案。
參數 | |
---|---|
bucketName | String : GCS 儲存桶名稱 |
filename | String :檔案名 |
退貨 | |
---|---|
InputStream | 文件內容出現ERROR(/InputStream) 。 |
下載文件
public void downloadFile (String remotePath, File destFile)
downloadFile(String)
的替代形式,允許呼叫者指定遠端內容應放置在的目標檔案。
參數 | |
---|---|
remotePath | String :要下載的檔案的遠端路徑,相對於特定實作的根。 |
destFile | File :放置下載內容的檔案。不應該存在。 |
投擲 | |
---|---|
BuildRetrievalError |
下載文件
public File downloadFile (String remoteFilePath)
從 GCS 下載檔案。
目前僅支援GCS路徑。
參數 | |
---|---|
remoteFilePath | String :gs://bucket/file/path 格式 GCS 路徑。 |
退貨 | |
---|---|
File | 本地文件 |
投擲 | |
---|---|
| com.android.tradefed.build.BuildRetrievalError |
BuildRetrievalError |
新鮮
public boolean isFresh (File localFile, String remotePath)
檢查本地文件的新鮮度。如果本地文件與遠端文件相同,則它是新鮮的。如果不是,則本機檔案已過時。這主要用於緩存。預設實作將始終傳回 true,因此如果檔案是不可變的,則它將永遠不需要檢查新鮮度。
參數 | |
---|---|
localFile | File :本地文件。 |
remotePath | String :遠端檔案路徑。 |
退貨 | |
---|---|
boolean | 如果本機檔案是最新的,則為 true,否則為 false。 |
投擲 | |
---|---|
BuildRetrievalError |
受保護的方法
清除快取
protected void clearCache ()