GCSBucketUtil

public class GCSBucketUtil
extends Object

java.lang.Object 中
   ↳ com.android.tradefed.util.GCSBucketUtil


用于从 Google Cloud Storage (GCS) 下载和上传文件的文件管理器。

该类不应在测试的作用域内使用(即IRemoteTest)。这是 已弃用,请改用 GCSFileDownloader

摘要

嵌套类

class GCSBucketUtil.GCSFileMetadata

GCS 中文件信息的简单封装容器。 

公共构造函数

GCSBucketUtil(String bucketName)

公共方法

CommandResult copy(String source, String dest)

将文件或目录复制到存储分区中,或从存储分区中复制文件或目录。

int getAttempts()
String getBotoConfig()
String getBotoPath()
String getBucketName()
boolean getNoClobber()
boolean getParallel()
boolean getRecursive()
long getRetryInterval()
long getTimeout()
boolean isFile(String path)

检查 GCS 文件是否为文件(文件夹)。

ls(Path bucketPath)

列出 GCS 路径下的文件。

CommandResult makeBucket(String projectId)

创建 GCS 存储分区。

String md5Hash(File localFile)

计算本地文件的 md5 哈希值。

CommandResult pull(Path bucketPath, File localFile)

从 GCS 存储分区下载文件或目录。

CommandResult pull(Path bucketPath)

将文件或目录从 GCS 存储分区下载到当前目录。

String pullContents(Path bucketPath)

从 GCS 存储分区下载文件并提取其内容。

CommandResult push(File localFile)

将本地文件或目录上传到 GCS 存储分区。

CommandResult push(File localFile, Path bucketPath)

将本地文件或目录上传到具有特定路径的 GCS 存储分区。

CommandResult pushString(String contents, Path bucketPath)

将字符串上传到 GCS 存储分区。

CommandResult remove(String pattern, boolean force)

从存储分区中移除文件或目录。

CommandResult remove(Path path, boolean force)

从存储分区中移除文件或目录。

CommandResult remove(Path path)

从存储分区中移除文件或目录。

CommandResult remove(String pattern)

从存储分区中移除文件或目录。

CommandResult removeBucket()

移除 GCS 存储分区

void setAttempts(int attempts)
void setBotoConfig(String botoConfig)
void setBotoPath(String botoPath)
void setBucketName(String bucketName)
void setNoClobber(boolean noClobber)
void setParallel(boolean parallel)
void setRecursive(boolean recursive)
void setRetryInterval(long retryInterval)
void setTimeout(long timeout, TimeUnit unit)
void setTimeoutMs(long timeout)
GCSBucketUtil.GCSFileMetadata stat(Path bucketPath)

获取 GCS 路径下文件的状态。

受保护的方法

IRunUtil getRunUtil()

公共构造函数

GCSBucketUtil

public GCSBucketUtil (String bucketName)

参数
bucketName String

公共方法

复制

public CommandResult copy (String source, 
                String dest)

将文件或目录复制到存储分区中,或从存储分区中复制文件或目录。

参数
source String:源文件或模式

dest String:目标文件或模式

返回
CommandResult 运算的 CommandResult 结果。

getAttempts

public int getAttempts ()

返回
int

getBotoConfig

public String getBotoConfig ()

返回
String

getBotoPath

public String getBotoPath ()

返回
String

getBucketName

public String getBucketName ()

返回
String

getNoClobber

public boolean getNoClobber ()

返回
boolean

getParallel

public boolean getParallel ()

返回
boolean

getRecursive(获取递归)

public boolean getRecursive ()

返回
boolean

getRetryInterval

public long getRetryInterval ()

返回
long

getTimeout

public long getTimeout ()

返回
long

isFile

public boolean isFile (String path)

检查 GCS 文件是否为文件(文件夹)。

如果文件名以“/”结尾,则表示文件夹。gsutil ls gs://filename 应返回 gs://filename(如果是一个文件)。gsutil ls gs://folder name 应该返回 如果此文件夹中有文件,则以该文件夹结尾。如果没有文件,它将返回 gs://folder/ 文件夹中。

参数
path String:相对于存储分区的路径。

返回
boolean 它是文件还是文件。

抛出
IOException

ls

public  ls (Path bucketPath)

列出 GCS 路径下的文件。

参数
bucketPath Path:GCS 路径

返回
String 列表,即 GCS 路径下的文件

抛出
IOException

makeBucket

public CommandResult makeBucket (String projectId)

创建 GCS 存储分区。

参数
projectId String

返回
CommandResult 运算的 CommandResult 结果。

抛出
IOException

md5 哈希

public String md5Hash (File localFile)

计算本地文件的 md5 哈希值。

参数
localFile File:本地文件

返回
String 本地文件的 md5 哈希值。

抛出
IOException

拉取

public CommandResult pull (Path bucketPath, 
                File localFile)

从 GCS 存储分区下载文件或目录。

参数
bucketPath Path:GCS 存储分区中的文件路径

localFile File:本地目标路径

返回
CommandResult 运算的 CommandResult 结果。

拉取

public CommandResult pull (Path bucketPath)

将文件或目录从 GCS 存储分区下载到当前目录。

参数
bucketPath Path:GCS 存储分区中的文件路径

返回
CommandResult 运算的 CommandResult 结果。

pullContents

public String pullContents (Path bucketPath)

从 GCS 存储分区下载文件并提取其内容。

参数
bucketPath Path:GCS 存储分区中的文件路径

返回
String 文件的字符串内容

推送

public CommandResult push (File localFile)

将本地文件或目录上传到 GCS 存储分区。

参数
localFile File:本地文件或目录

返回
CommandResult 运算的 CommandResult 结果。

推送

public CommandResult push (File localFile, 
                Path bucketPath)

将本地文件或目录上传到具有特定路径的 GCS 存储分区。

参数
localFile File:本地文件或目录

bucketPath Path:GCS 存储分区中的文件路径

返回
CommandResult 运算的 CommandResult 结果。

推送字符串

public CommandResult pushString (String contents, 
                Path bucketPath)

将字符串上传到 GCS 存储分区。

参数
contents String:文件内容,以字符串表示

bucketPath Path:GCS 存储分区中的文件路径

返回
CommandResult 运算的 CommandResult 结果。

移除

public CommandResult remove (String pattern, 
                boolean force)

从存储分区中移除文件或目录。

参数
pattern String:要移除的文件、目录或模式。

force boolean:是否忽略失败并以静默方式继续(不会抛出)

返回
CommandResult

移除

public CommandResult remove (Path path, 
                boolean force)

从存储分区中移除文件或目录。

参数
path Path:要移除的路径

force boolean:如果文件不存在,是否失败

返回
CommandResult

移除

public CommandResult remove (Path path)

从存储分区中移除文件或目录。

参数
path Path:要移除的路径

返回
CommandResult

移除

public CommandResult remove (String pattern)

从存储分区中移除文件或目录。

参数
pattern String:要移除的文件、目录或模式。

返回
CommandResult

removeBucket

public CommandResult removeBucket ()

移除 GCS 存储分区

返回
CommandResult

抛出
IOException

setAttempts

public void setAttempts (int attempts)

参数
attempts int

setBotoConfig

public void setBotoConfig (String botoConfig)

参数
botoConfig String

setBotoPath

public void setBotoPath (String botoPath)

参数
botoPath String

setBucketName

public void setBucketName (String bucketName)

参数
bucketName String

setNoClobber

public void setNoClobber (boolean noClobber)

参数
noClobber boolean

setParallel

public void setParallel (boolean parallel)

参数
parallel boolean

setRecursive

public void setRecursive (boolean recursive)

参数
recursive boolean

setRetryInterval

public void setRetryInterval (long retryInterval)

参数
retryInterval long

setTimeout

public void setTimeout (long timeout, 
                TimeUnit unit)

参数
timeout long

unit TimeUnit

setTimeoutMs

public void setTimeoutMs (long timeout)

参数
timeout long

统计数据

public GCSBucketUtil.GCSFileMetadata stat (Path bucketPath)

获取 GCS 路径下文件的状态。

参数
bucketPath Path:GCS 路径

返回
GCSBucketUtil.GCSFileMetadata GCSFileMetadata(适用于 GCS 路径)

抛出
IOException

受保护的方法

getRunUtil

protected IRunUtil getRunUtil ()

返回
IRunUtil