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