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 ()