自 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.
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
GCSFileDownloaderBase
public
class
GCSFileDownloaderBase
extends GCSCommon
用于从 Google Cloud Storage (GCS) 下载文件的文件下载器。
摘要
常量
GCS_APPROX_PREFIX
public static final String GCS_APPROX_PREFIX
常量值:
"gs:/"
GCS_PREFIX
public static final String GCS_PREFIX
常量值:
"gs://"
字段
mCreateEmptyFile
protected Boolean mCreateEmptyFile
公共构造函数
GCSFileDownloaderBase
public GCSFileDownloaderBase ()
GCSFileDownloaderBase
public GCSFileDownloaderBase (Boolean createEmptyFile)
| 参数 |
createEmptyFile |
Boolean |
公共方法
createTempFileForRemote
public static File createTempFileForRemote (String remoteFilePath,
File rootDir)
在临时磁盘上创建一个唯一的文件,用于存放具有指定路径的下载文件。
根据路径中的基本文件名构造文件名
| 参数 |
remoteFilePath |
String:用于构造名称的远程路径 |
rootDir |
File |
downloadFile
public InputStream downloadFile (String bucketName,
String filename)
从 GCS 存储分区文件下载文件。
| 参数 |
bucketName |
String:GCS 存储分区名称 |
filename |
String:文件名 |
downloadFile
public void downloadFile (String remotePath,
File destFile)
| 参数 |
remotePath |
String |
destFile |
File |
downloadFile
public File downloadFile (String remoteFilePath)
public StorageObject getRemoteFileMetaData (String bucketName,
String remoteFilename)
| 参数 |
bucketName |
String |
remoteFilename |
String |
isRemoteFolder
public boolean isRemoteFolder (String bucketName,
String filename)
检查给定的文件名是否为文件夹。
GCS 中有 2 种类型的文件夹:1. 通过界面明确创建。相应文件夹是一个大小为 0 的文本文件(它是一个对象)。2. 上传文件时,系统会创建其所有父文件夹,但这些文件夹在 GCS 中不存在(不是对象)。此函数适用于这两种情况。但是,我们不应尝试下载大小为 0 的文件夹。
| 参数 |
bucketName |
String:是 GCS 存储分区名称。 |
filename |
String:是存储分区的相对路径。 |
| 返回 |
boolean |
如果相应文件名是文件夹,则返回 true,否则返回 false。 |
sanitizeDirectoryName
public String sanitizeDirectoryName (String name)
受保护的方法
createTempFile
protected File createTempFile (String remoteFilePath,
File rootDir)
| 参数 |
remoteFilePath |
String |
rootDir |
File |
downloadFile
protected void downloadFile (String bucketName,
String remoteFilename,
File localFile)
| 参数 |
bucketName |
String |
remoteFilename |
String |
localFile |
File |
getStorage
protected Storage getStorage ()
listRemoteFilesUnderFolder
protected void listRemoteFilesUnderFolder (String bucketName,
String folder,
subFiles,
subFolders)
| 参数 |
bucketName |
String |
folder |
String |
subFiles |
|
subFolders |
|
parseGcsPath
protected String[] parseGcsPath (String remotePath)
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-12-04。
[[["易于理解","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-12-04。"],[],[]]