自 2026 年起,为了与我们的主干稳定开发模型保持一致,并确保生态系统的平台稳定性,我们将在第 2 季度和第 4 季度将源代码发布到 AOSP。对于构建 AOSP 和向 AOSP 贡献代码,我们建议使用 android-latest-release 而不是 aosp-main。android-latest-release 清单分支将始终引用推送到 AOSP 的最新版本。如需了解详情,请参阅 AOSP 变更。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
GCSFileDownloader
public
class
GCSFileDownloader
extends GCSFileDownloaderBase
implements
IFileDownloader
用于从 Google Cloud Storage (GCS) 下载文件的文件下载器。
摘要
公共构造函数
GCSFileDownloader
public GCSFileDownloader ()
GCSFileDownloader
public GCSFileDownloader (Boolean createEmptyFile)
| 参数 |
createEmptyFile |
Boolean |
GCSFileDownloader
public GCSFileDownloader (File jsonKeyFile)
GCSFileDownloader
public GCSFileDownloader (File jsonKeyFile,
Boolean createEmptyFile)
| 参数 |
jsonKeyFile |
File |
createEmptyFile |
Boolean |
公共方法
createTempFileForRemote
public static File createTempFileForRemote (String remoteFilePath,
File rootDir)
| 参数 |
remoteFilePath |
String |
rootDir |
File |
downloadFile
public void downloadFile (String remotePath,
File destFile)
| 参数 |
remotePath |
String |
destFile |
File |
downloadFile
public File downloadFile (String remoteFilePath)
从 GCS 下载文件。
目前仅支持 GCS 路径。
| 参数 |
remoteFilePath |
String:采用 gs://bucket/file/path 格式的 GCS 路径。 |
isFresh
public boolean isFresh (File localFile,
String remotePath)
检查本地文件的新鲜度。如果本地文件与远程文件相同,则表示本地文件是最新的。否则,本地文件已过时。这主要用于缓存。默认实现始终会返回 true,因此如果文件是不可变的,则永远无需检查新鲜度。
| 参数 |
localFile |
File:本地文件。 |
remotePath |
String:远程文件路径。 |
| 返回 |
boolean |
如果本地文件是新鲜的,则返回 true,否则返回 false。 |
受保护的方法
clearCache
protected void clearCache ()
downloadFile
protected void downloadFile (String bucketName,
String remoteFilename,
File localFile)
| 参数 |
bucketName |
String |
remoteFilename |
String |
localFile |
File |
getStorage
protected Storage getStorage ( scopes)
替换了基准中的实现,以支持基于 TF 选项的凭据。
parseGcsPath
protected String[] parseGcsPath (String remotePath)
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[]]