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 ファイルがファイルかどうか(フォルダかどうか)を確認します。 |
List<String>
|
ls(Path bucketPath)
GCS パスにあるファイルのリストを取得します。 |
CommandResult
|
makeBucket(String projectId)
GCS バケットを作成します。 |
String
|
md5Hash(File localFile)
ローカル ファイルの md5 ハッシュを計算します。 |
CommandResult
|
pull(Path bucketPath)
GCS バケットから現在のディレクトリにファイルまたはディレクトリをダウンロードします。 |
CommandResult
|
pull(Path bucketPath, File localFile)
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 オペレーションの結果。 |
| 例外 | |
|---|---|
IOException |
|
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 |
ファイルかどうかを判断します。 |
| 例外 | |
|---|---|
|
java.io.IOException |
IOException |
|
ls
public List<String> ls (Path bucketPath)
GCS パスにあるファイルを一覧表示します。
| パラメータ | |
|---|---|
bucketPath |
Path: GCS パス |
| 戻り値 | |
|---|---|
List<String> |
GCS パスにあるファイルの String のリスト |
| 例外 | |
|---|---|
|
java.io.IOException |
IOException |
|
makeBucket
public CommandResult makeBucket (String projectId)
GCS バケットを作成します。
| パラメータ | |
|---|---|
projectId |
String |
| 戻り値 | |
|---|---|
CommandResult |
オペレーションの CommandResult 結果。 |
| 例外 | |
|---|---|
|
java.io.IOException |
IOException |
|
md5Hash
public String md5Hash (File localFile)
ローカル ファイルの md5 ハッシュを計算します。
| パラメータ | |
|---|---|
localFile |
File: ローカル ファイル |
| 戻り値 | |
|---|---|
String |
ローカル ファイルの md5 ハッシュ。 |
| 例外 | |
|---|---|
|
java.io.IOException |
IOException |
|
pull
public CommandResult pull (Path bucketPath)
GCS バケットから現在のディレクトリにファイルまたはディレクトリをダウンロードします。
| パラメータ | |
|---|---|
bucketPath |
Path: GCS バケット内のファイルパス |
| 戻り値 | |
|---|---|
CommandResult |
CommandResult オペレーションの結果。 |
| 例外 | |
|---|---|
IOException |
|
pull
public CommandResult pull (Path bucketPath, File localFile)
GCS バケットからファイルまたはディレクトリをダウンロードします。
| パラメータ | |
|---|---|
bucketPath |
Path: GCS バケット内のファイルパス |
localFile |
File: ローカルの宛先パス |
| 戻り値 | |
|---|---|
CommandResult |
オペレーションの CommandResult 結果。 |
| 例外 | |
|---|---|
IOException |
|
pullContents
public String pullContents (Path bucketPath)
GCS バケットからファイルをダウンロードし、その内容を抽出します。
| パラメータ | |
|---|---|
bucketPath |
Path: GCS バケット内のファイルパス |
| 戻り値 | |
|---|---|
String |
ファイルの文字列コンテンツ |
| 例外 | |
|---|---|
IOException |
|
push
public CommandResult push (File localFile)
ローカル ファイルまたはディレクトリを GCS バケットにアップロードします。
| パラメータ | |
|---|---|
localFile |
File: ローカル ファイルまたはディレクトリ |
| 戻り値 | |
|---|---|
CommandResult |
CommandResult オペレーションの結果。 |
| 例外 | |
|---|---|
IOException |
|
push
public CommandResult push (File localFile, Path bucketPath)
特定のパスを使用してローカル ファイルまたはディレクトリを GCS バケットにアップロードします。
| パラメータ | |
|---|---|
localFile |
File: ローカル ファイルまたはディレクトリ |
bucketPath |
Path: GCS バケット内のファイルパス |
| 戻り値 | |
|---|---|
CommandResult |
CommandResult オペレーションの結果。 |
| 例外 | |
|---|---|
IOException |
|
pushString
public CommandResult pushString (String contents, Path bucketPath)
文字列を GCS バケットにアップロードします。
| パラメータ | |
|---|---|
contents |
String: ファイルの内容(文字列) |
bucketPath |
Path: GCS バケット内のファイルパス |
| 戻り値 | |
|---|---|
CommandResult |
CommandResult オペレーションの結果。 |
| 例外 | |
|---|---|
IOException |
|
削除
public CommandResult remove (String pattern, boolean force)
バケットからファイルまたはディレクトリを削除します。
| パラメータ | |
|---|---|
pattern |
String: 削除するファイル、ディレクトリ、またはパターン。 |
force |
boolean: 失敗を無視してサイレントに続行するかどうか(スローされません) |
| 戻り値 | |
|---|---|
CommandResult |
|
| 例外 | |
|---|---|
IOException |
|
削除
public CommandResult remove (Path path, boolean force)
バケットからファイルまたはディレクトリを削除します。
| パラメータ | |
|---|---|
path |
Path: 削除するパス |
force |
boolean: ファイルが存在しない場合に失敗するかどうか |
| 戻り値 | |
|---|---|
CommandResult |
|
| 例外 | |
|---|---|
IOException |
|
削除
public CommandResult remove (Path path)
バケットからファイルまたはディレクトリを削除します。
| パラメータ | |
|---|---|
path |
Path: 削除するパス |
| 戻り値 | |
|---|---|
CommandResult |
|
| 例外 | |
|---|---|
IOException |
|
削除
public CommandResult remove (String pattern)
バケットからファイルまたはディレクトリを削除します。
| パラメータ | |
|---|---|
pattern |
String: 削除するファイル、ディレクトリ、またはパターン。 |
| 戻り値 | |
|---|---|
CommandResult |
|
| 例外 | |
|---|---|
IOException |
|
removeBucket
public CommandResult removeBucket ()
GCS バケットを削除する
| 戻り値 | |
|---|---|
CommandResult |
|
| 例外 | |
|---|---|
|
java.io.IOException |
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 |
stat
public GCSBucketUtil.GCSFileMetadata stat (Path bucketPath)
GCS パスのファイルの状態を取得します。
| パラメータ | |
|---|---|
bucketPath |
Path: GCS パス |
| 戻り値 | |
|---|---|
GCSBucketUtil.GCSFileMetadata |
GCS パスの GCSFileMetadata |
| 例外 | |
|---|---|
|
java.io.IOException |
IOException |
|