GCSバケット利用率

public class GCSBucketUtil
extends Object

java.lang.オブジェクト
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 ()

パブリックコンストラクター

GCSバケット利用率

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

getBotoPath

public String getBotoPath ()

戻り値
String

getバケット名

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

isファイル

public boolean isFile (String path)

GCS ファイルがファイルであるか、ファイル (フォルダー) ではないことを確認してください。

ファイル名が「/」で終わる場合、それはフォルダーです。 gsutil ls gs://filename は、ファイルの場合は gs://filename を返す必要があります。 gsutil ls gs://folder name は、フォルダー内にファイルがある場合、フォルダー内のファイルを返す必要があります。フォルダー内にファイルがない場合は、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

setBotoConfig

public void setBotoConfig (String botoConfig)

パラメーター
botoConfig String

setBotoPath

public void setBotoPath (String botoPath)

パラメーター
botoPath String

セットバケット名

public void setBucketName (String bucketName)

パラメーター
bucketName String

setNoClobber

public void setNoClobber (boolean noClobber)

パラメーター
noClobber boolean

setParallel

public void setParallel (boolean parallel)

パラメーター
parallel boolean

セット再帰的

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 GCS パスのGCSFileMetadata

投げる
IO例外

保護されたメソッド

getRunUtil

protected IRunUtil getRunUtil ()

戻り値
IRunUtil