GCSBucketUtil
public
class
GCSBucketUtil
extends Object
| java.lang.Object | |
| ↳ | com.android.tradefed.util.GCSBucketUtil |
File manager per scaricare e caricare file da Google Cloud Storage (GCS).
Questa classe NON deve essere utilizzata dall'ambito di un test (ovvero IRemoteTest). Questo criterio è
deprecato. Utilizza GCSFileDownloader.
Riepilogo
Classi nidificate | |
|---|---|
class |
GCSBucketUtil.GCSFileMetadata
Wrapper semplice per le informazioni sui file in GCS. |
Costruttori pubblici | |
|---|---|
GCSBucketUtil(String bucketName)
|
|
Metodi pubblici | |
|---|---|
CommandResult
|
copy(String source, String dest)
Copia un file o una directory nel bucket o dal bucket. |
int
|
getAttempts()
|
String
|
getBotoConfig()
|
String
|
getBotoPath()
|
String
|
getBucketName()
|
boolean
|
getNoClobber()
|
boolean
|
getParallel()
|
boolean
|
getRecursive()
|
long
|
getRetryInterval()
|
long
|
getTimeout()
|
boolean
|
isFile(String path)
Controlla se un file GCS è un file o una cartella. |
List<String>
|
ls(Path bucketPath)
Elenca i file in un percorso GCS. |
CommandResult
|
makeBucket(String projectId)
Crea il bucket GCS. |
String
|
md5Hash(File localFile)
Calcola l'hash MD5 per il file locale. |
CommandResult
|
pull(Path bucketPath)
Scarica un file o una directory da un bucket GCS nella directory corrente. |
CommandResult
|
pull(Path bucketPath, File localFile)
Scarica un file o una directory da un bucket GCS. |
String
|
pullContents(Path bucketPath)
Scarica un file da un bucket GCS ed estraine i contenuti. |
CommandResult
|
push(File localFile)
Carica un file o una directory locale in un bucket GCS. |
CommandResult
|
push(File localFile, Path bucketPath)
Carica un file o una directory locale in un bucket GCS con un percorso specifico. |
CommandResult
|
pushString(String contents, Path bucketPath)
Carica una stringa in un bucket GCS. |
CommandResult
|
remove(String pattern, boolean force)
Rimuovi un file o una directory dal bucket. |
CommandResult
|
remove(Path path, boolean force)
Rimuovi un file o una directory dal bucket. |
CommandResult
|
remove(Path path)
Rimuovi un file o una directory dal bucket. |
CommandResult
|
remove(String pattern)
Rimuovi un file o una directory dal bucket. |
CommandResult
|
removeBucket()
Rimuovi il bucket 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)
Ottieni lo stato del file per il percorso GCS. |
Metodi protetti | |
|---|---|
IRunUtil
|
getRunUtil()
|
Costruttori pubblici
GCSBucketUtil
public GCSBucketUtil (String bucketName)
| Parametri | |
|---|---|
bucketName |
String |
Metodi pubblici
copia
public CommandResult copy (String source, String dest)
Copia un file o una directory nel bucket o dal bucket.
| Parametri | |
|---|---|
source |
String: File o pattern di origine |
dest |
String: File o pattern di destinazione |
| Resi | |
|---|---|
CommandResult |
CommandResult risultato dell'operazione. |
| Genera | |
|---|---|
IOException |
|
getAttempts
public int getAttempts ()
| Resi | |
|---|---|
int |
|
getBotoConfig
public String getBotoConfig ()
| Resi | |
|---|---|
String |
|
getBotoPath
public String getBotoPath ()
| Resi | |
|---|---|
String |
|
getBucketName
public String getBucketName ()
| Resi | |
|---|---|
String |
|
getNoClobber
public boolean getNoClobber ()
| Resi | |
|---|---|
boolean |
|
getParallel
public boolean getParallel ()
| Resi | |
|---|---|
boolean |
|
getRecursive
public boolean getRecursive ()
| Resi | |
|---|---|
boolean |
|
getRetryInterval
public long getRetryInterval ()
| Resi | |
|---|---|
long |
|
getTimeout
public long getTimeout ()
| Resi | |
|---|---|
long |
|
isFile
public boolean isFile (String path)
Controlla se un file GCS è un file o una cartella.
Se il nome file termina con "/", si tratta di una cartella. gsutil ls gs://filename dovrebbe restituire gs://filename se si tratta di un file. gsutil ls gs://folder name dovrebbe restituire i file nella cartella se sono presenti file. e restituirà gs://folder/ se non sono presenti file nella cartella.
| Parametri | |
|---|---|
path |
String: il percorso relativo al bucket. |
| Resi | |
|---|---|
boolean |
è un file o non è un file. |
| Genera | |
|---|---|
|
java.io.IOException |
IOException |
|
ls
public List<String> ls (Path bucketPath)
Elenca i file in un percorso GCS.
| Parametri | |
|---|---|
bucketPath |
Path: il percorso GCS |
| Resi | |
|---|---|
List<String> |
Un elenco di String che sono file nel percorso GCS |
| Genera | |
|---|---|
|
java.io.IOException |
IOException |
|
makeBucket
public CommandResult makeBucket (String projectId)
Crea il bucket GCS.
| Parametri | |
|---|---|
projectId |
String |
| Resi | |
|---|---|
CommandResult |
CommandResult risultato dell'operazione. |
| Genera | |
|---|---|
|
java.io.IOException |
IOException |
|
md5Hash
public String md5Hash (File localFile)
Calcola l'hash MD5 per il file locale.
| Parametri | |
|---|---|
localFile |
File: un file locale |
| Resi | |
|---|---|
String |
l'hash MD5 del file locale. |
| Genera | |
|---|---|
|
java.io.IOException |
IOException |
|
eseguire il pull
public CommandResult pull (Path bucketPath)
Scarica un file o una directory da un bucket GCS nella directory corrente.
| Parametri | |
|---|---|
bucketPath |
Path: percorso del file nel bucket GCS |
| Resi | |
|---|---|
CommandResult |
CommandResult risultato dell'operazione. |
| Genera | |
|---|---|
IOException |
|
eseguire il pull
public CommandResult pull (Path bucketPath, File localFile)
Scarica un file o una directory da un bucket GCS.
| Parametri | |
|---|---|
bucketPath |
Path: percorso del file nel bucket GCS |
localFile |
File: Percorso della destinazione locale |
| Resi | |
|---|---|
CommandResult |
CommandResult risultato dell'operazione. |
| Genera | |
|---|---|
IOException |
|
pullContents
public String pullContents (Path bucketPath)
Scarica un file da un bucket GCS ed estraine i contenuti.
| Parametri | |
|---|---|
bucketPath |
Path: percorso del file nel bucket GCS |
| Resi | |
|---|---|
String |
Contenuti della stringa del file |
| Genera | |
|---|---|
IOException |
|
eseguire il push
public CommandResult push (File localFile)
Carica un file o una directory locale in un bucket GCS.
| Parametri | |
|---|---|
localFile |
File: File o directory locale |
| Resi | |
|---|---|
CommandResult |
CommandResult risultato dell'operazione. |
| Genera | |
|---|---|
IOException |
|
eseguire il push
public CommandResult push (File localFile, Path bucketPath)
Carica un file o una directory locale in un bucket GCS con un percorso specifico.
| Parametri | |
|---|---|
localFile |
File: File o directory locale |
bucketPath |
Path: percorso del file nel bucket GCS |
| Resi | |
|---|---|
CommandResult |
CommandResult risultato dell'operazione. |
| Genera | |
|---|---|
IOException |
|
pushString
public CommandResult pushString (String contents, Path bucketPath)
Carica una stringa in un bucket GCS.
| Parametri | |
|---|---|
contents |
String: Contenuto del file, come stringa |
bucketPath |
Path: percorso del file nel bucket GCS |
| Resi | |
|---|---|
CommandResult |
CommandResult risultato dell'operazione. |
| Genera | |
|---|---|
IOException |
|
rimuovi
public CommandResult remove (String pattern, boolean force)
Rimuovi un file o una directory dal bucket.
| Parametri | |
|---|---|
pattern |
String: File, directory o pattern da rimuovere. |
force |
boolean: indica se ignorare gli errori e continuare in modalità silenziosa (non verrà generata un'eccezione) |
| Resi | |
|---|---|
CommandResult |
|
| Genera | |
|---|---|
IOException |
|
rimuovi
public CommandResult remove (Path path, boolean force)
Rimuovi un file o una directory dal bucket.
| Parametri | |
|---|---|
path |
Path: Percorso da rimuovere |
force |
boolean: indica se l'operazione deve non riuscire se il file non esiste |
| Resi | |
|---|---|
CommandResult |
|
| Genera | |
|---|---|
IOException |
|
rimuovi
public CommandResult remove (Path path)
Rimuovi un file o una directory dal bucket.
| Parametri | |
|---|---|
path |
Path: Percorso da rimuovere |
| Resi | |
|---|---|
CommandResult |
|
| Genera | |
|---|---|
IOException |
|
rimuovi
public CommandResult remove (String pattern)
Rimuovi un file o una directory dal bucket.
| Parametri | |
|---|---|
pattern |
String: File, directory o pattern da rimuovere. |
| Resi | |
|---|---|
CommandResult |
|
| Genera | |
|---|---|
IOException |
|
removeBucket
public CommandResult removeBucket ()
Rimuovi il bucket GCS
| Resi | |
|---|---|
CommandResult |
|
| Genera | |
|---|---|
|
java.io.IOException |
IOException |
|
setAttempts
public void setAttempts (int attempts)
| Parametri | |
|---|---|
attempts |
int |
setBotoConfig
public void setBotoConfig (String botoConfig)
| Parametri | |
|---|---|
botoConfig |
String |
setBotoPath
public void setBotoPath (String botoPath)
| Parametri | |
|---|---|
botoPath |
String |
setBucketName
public void setBucketName (String bucketName)
| Parametri | |
|---|---|
bucketName |
String |
setNoClobber
public void setNoClobber (boolean noClobber)
| Parametri | |
|---|---|
noClobber |
boolean |
setParallel
public void setParallel (boolean parallel)
| Parametri | |
|---|---|
parallel |
boolean |
setRecursive
public void setRecursive (boolean recursive)
| Parametri | |
|---|---|
recursive |
boolean |
setRetryInterval
public void setRetryInterval (long retryInterval)
| Parametri | |
|---|---|
retryInterval |
long |
setTimeout
public void setTimeout (long timeout,
TimeUnit unit)| Parametri | |
|---|---|
timeout |
long |
unit |
TimeUnit |
setTimeoutMs
public void setTimeoutMs (long timeout)
| Parametri | |
|---|---|
timeout |
long |
stat
public GCSBucketUtil.GCSFileMetadata stat (Path bucketPath)
Ottieni lo stato del file per il percorso GCS.
| Parametri | |
|---|---|
bucketPath |
Path: il percorso GCS |
| Resi | |
|---|---|
GCSBucketUtil.GCSFileMetadata |
GCSFileMetadata per il percorso GCS |
| Genera | |
|---|---|
|
java.io.IOException |
IOException |
|