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操作結果。

取得嘗試

public int getAttempts ()

退貨
int

取得BotoConfig

public String getBotoConfig ()

退貨
String

取得BotoPath

public String getBotoPath ()

退貨
String

取得桶名

public String getBucketName ()

退貨
String

取得NoClobber

public boolean getNoClobber ()

退貨
boolean

取得並行

public boolean getParallel ()

退貨
boolean

遞迴獲取

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它是一個文件或不是一個文件。

投擲
IO異常

LS

public  ls (Path bucketPath)

列出 GCS 路徑下的檔案。

參數
bucketPath Path :GCS路徑

退貨
GCS 路徑下的檔案String列表

投擲
IO異常

製作桶

public CommandResult makeBucket (String projectId)

製作 GCS 桶。

參數
projectId String

退貨
CommandResult CommandResult操作結果。

投擲
IO異常

md5哈希值

public String md5Hash (File localFile)

計算本地檔案的 md5 哈希值。

參數
localFile File :本地文件

退貨
String本機檔案的 md5 哈希值。

投擲
IO異常

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操作結果。

拉取內容

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

刪除桶

public CommandResult removeBucket ()

卸下 GCS 鏟鬥

退貨
CommandResult

投擲
IO異常

設定嘗試次數

public void setAttempts (int attempts)

參數
attempts int

設定BotoConfig

public void setBotoConfig (String botoConfig)

參數
botoConfig String

設定BotoPath

public void setBotoPath (String botoPath)

參數
botoPath String

設定Bucket名稱

public void setBucketName (String bucketName)

參數
bucketName String

設定無破壞

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

投擲
IO異常

受保護的方法

取得運行工具

protected IRunUtil getRunUtil ()

退貨
IRunUtil