GCSBucketUtil

public class GCSBucketUtil
extends Object

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


文件管理器,用於從 Google 雲存儲 (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操作結果。

獲取嘗試次數

public int getAttempts ()

退貨
int

getBotoConfig

public String getBotoConfig ()

退貨
String

獲取BotoPath

public String getBotoPath ()

退貨
String

獲取桶名

public String getBucketName ()

退貨
String

得到無障礙

public boolean getNoClobber ()

退貨
boolean

獲得平行

public boolean getParallel ()

退貨
boolean

get遞歸

public boolean getRecursive ()

退貨
boolean

獲取重試間隔

public long getRetryInterval ()

退貨
long

超時

public long getTimeout ()

退貨
long

是文件

public boolean isFile (String path)

檢查 GCS 文件是文件還是不是文件(文件夾)。

如果文件名以“/”結尾,那麼它就是一個文件夾。 gsutil ls gs://filename 應該返回 gs://filename 如果它是一個文件。如果文件夾中有文件,gsutil ls gs://文件夾名稱應該返回文件夾中的文件。如果文件夾中沒有文件,它將返回 gs://folder/ 。

參數
path String : 相對於桶的路徑..

退貨
boolean它是一個文件或不是一個文件。

投擲
異常

ls

public  ls (Path bucketPath)

列出 GCS 路徑下的文件。

參數
bucketPath Path :GCS 路徑

退貨
GCS 路徑下的文件的ERROR(/String)列表

投擲
異常

製作桶

public CommandResult makeBucket (String projectId)

製作 GCS 桶。

參數
projectId String

退貨
CommandResult CommandResult操作結果。

投擲
異常

md5哈希

public String md5Hash (File localFile)

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

參數
localFile File :本地文件

退貨
String本地文件的 md5 散列。

投擲
異常

public CommandResult pull (Path bucketPath, 
                File localFile)

從 GCS 存儲桶下載文件或目錄。

參數
bucketPath Path : GCS bucket中的文件路徑

localFile File :本地目標路徑

退貨
CommandResult CommandResult操作結果。

public CommandResult pull (Path bucketPath)

將文件或目錄從 GCS 存儲桶下載到當前目錄。

參數
bucketPath Path : GCS bucket中的文件路徑

退貨
CommandResult CommandResult操作結果。

拉內容

public String pullContents (Path bucketPath)

從 GCS 存儲桶下載文件並提取其內容。

參數
bucketPath Path : GCS bucket中的文件路徑

退貨
String文件的字符串內容

public CommandResult push (File localFile)

將本地文件或目錄上傳到 GCS 存儲桶。

參數
localFile File : 本地文件或目錄

退貨
CommandResult CommandResult操作結果。

public CommandResult push (File localFile, 
                Path bucketPath)

將本地文件或目錄上傳到具有特定路徑的 GCS 存儲桶。

參數
localFile File : 本地文件或目錄

bucketPath Path : GCS bucket中的文件路徑

退貨
CommandResult CommandResult操作結果。

推送字符串

public CommandResult pushString (String contents, 
                Path bucketPath)

將字符串上傳到 GCS 存儲桶。

參數
contents String :文件內容,作為字符串

bucketPath Path : GCS bucket中的文件路徑

退貨
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

刪除桶

public CommandResult removeBucket ()

刪除 GCS 存儲桶

退貨
CommandResult

投擲
異常

設置嘗試次數

public void setAttempts (int attempts)

參數
attempts int

設置BotoConfig

public void setBotoConfig (String botoConfig)

參數
botoConfig String

設置BotoPath

public void setBotoPath (String botoPath)

參數
botoPath String

設置桶名

public void setBucketName (String bucketName)

參數
bucketName String

設置NoClobber

public void setNoClobber (boolean noClobber)

參數
noClobber boolean

設置平行

public void setParallel (boolean parallel)

參數
parallel boolean

設置遞歸

public void setRecursive (boolean recursive)

參數
recursive boolean

設置重試間隔

public void setRetryInterval (long retryInterval)

參數
retryInterval long

設置超時

public void setTimeout (long timeout, 
                TimeUnit unit)

參數
timeout long

unit TimeUnit

設置超時時間

public void setTimeoutMs (long timeout)

參數
timeout long

狀態

public GCSBucketUtil.GCSFileMetadata stat (Path bucketPath)

獲取 GCS 路徑的文件狀態。

參數
bucketPath Path :GCS 路徑

退貨
GCSBucketUtil.GCSFileMetadata GCS 路徑的GCSFileMetadata

投擲
異常

受保護的方法

getRunUtil

protected IRunUtil getRunUtil ()

退貨
IRunUtil