GCSBucketUtil

public class GCSBucketUtil
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.GCSBucketUtil


Gestionnaire de fichiers permettant de télécharger et d'importer des fichiers depuis Google Cloud Storage (GCS).

Cette classe ne doit PAS être utilisée dans le champ d'application d'un test (c'est-à-dire IRemoteTest). Cette règle est obsolète. Veuillez utiliser GCSFileDownloader à la place.

Résumé

Classes imbriquées

class GCSBucketUtil.GCSFileMetadata

Wrapper simple pour les informations sur les fichiers dans GCS. 

Constructeurs publics

GCSBucketUtil(String bucketName)

Méthodes publiques

CommandResult copy(String source, String dest)

Copiez un fichier ou un répertoire vers ou depuis le bucket.

int getAttempts()
String getBotoConfig()
String getBotoPath()
String getBucketName()
boolean getNoClobber()
boolean getParallel()
boolean getRecursive()
long getRetryInterval()
long getTimeout()
boolean isFile(String path)

Vérifiez si un fichier GCS est un fichier ou un dossier.

List<String> ls(Path bucketPath)

Lister les fichiers sous un chemin d'accès GCS.

CommandResult makeBucket(String projectId)

Créez le bucket GCS.

String md5Hash(File localFile)

Calculez le hachage MD5 du fichier local.

CommandResult pull(Path bucketPath)

Téléchargez un fichier ou un répertoire depuis un bucket GCS vers le répertoire actuel.

CommandResult pull(Path bucketPath, File localFile)

Téléchargez un fichier ou un répertoire à partir d'un bucket GCS.

String pullContents(Path bucketPath)

Téléchargez un fichier à partir d'un bucket GCS et extrayez son contenu.

CommandResult push(File localFile)

Importez un fichier ou un répertoire local dans un bucket GCS.

CommandResult push(File localFile, Path bucketPath)

Importez un fichier ou un répertoire local dans un bucket GCS avec un chemin d'accès spécifique.

CommandResult pushString(String contents, Path bucketPath)

Importer une chaîne dans un bucket GCS.

CommandResult remove(String pattern, boolean force)

Supprimez un fichier ou un répertoire du bucket.

CommandResult remove(Path path, boolean force)

Supprimez un fichier ou un répertoire du bucket.

CommandResult remove(Path path)

Supprimez un fichier ou un répertoire du bucket.

CommandResult remove(String pattern)

Supprimez un fichier ou un répertoire du bucket.

CommandResult removeBucket()

Supprimer le 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)

Obtenez l'état du fichier pour le chemin d'accès GCS.

Méthodes protégées

IRunUtil getRunUtil()

Constructeurs publics

GCSBucketUtil

public GCSBucketUtil (String bucketName)

Paramètres
bucketName String

Méthodes publiques

copier

public CommandResult copy (String source, 
                String dest)

Copiez un fichier ou un répertoire vers ou depuis le bucket.

Paramètres
source String : fichier ou modèle source

dest String : fichier ou modèle de destination

Renvoie
CommandResult Résultat CommandResult de l'opération.

Génère
IOException

getAttempts

public int getAttempts ()

Renvoie
int

getBotoConfig

public String getBotoConfig ()

Renvoie
String

getBotoPath

public String getBotoPath ()

Renvoie
String

getBucketName

public String getBucketName ()

Renvoie
String

getNoClobber

public boolean getNoClobber ()

Renvoie
boolean

getParallel

public boolean getParallel ()

Renvoie
boolean

getRecursive

public boolean getRecursive ()

Renvoie
boolean

getRetryInterval

public long getRetryInterval ()

Renvoie
long

getTimeout

public long getTimeout ()

Renvoie
long

isFile

public boolean isFile (String path)

Vérifiez si un fichier GCS est un fichier ou un dossier.

Si le nom de fichier se termine par "/", il s'agit d'un dossier. gsutil ls gs://nom_fichier doit renvoyer gs://nom_fichier s'il s'agit d'un fichier. gsutil ls gs://nom_dossier doit renvoyer les fichiers du dossier, s'il en contient. Il renverra gs://folder/ si le dossier ne contient aucun fichier.

Paramètres
path String : chemin d'accès relatif au bucket.

Renvoie
boolean s'il s'agit d'un fichier ou non.

Génère
java.io.IOException
IOException

ls

public List<String> ls (Path bucketPath)

Lister les fichiers sous un chemin d'accès GCS.

Paramètres
bucketPath Path : chemin d'accès GCS

Renvoie
List<String> Liste des String qui sont des fichiers sous le chemin d'accès GCS

Génère
java.io.IOException
IOException

makeBucket

public CommandResult makeBucket (String projectId)

Créez le bucket GCS.

Paramètres
projectId String

Renvoie
CommandResult Résultat CommandResult de l'opération.

Génère
java.io.IOException
IOException

md5Hash

public String md5Hash (File localFile)

Calculez le hachage MD5 du fichier local.

Paramètres
localFile File : un fichier local

Renvoie
String Hachage MD5 du fichier local.

Génère
java.io.IOException
IOException

récupérer

public CommandResult pull (Path bucketPath)

Téléchargez un fichier ou un répertoire depuis un bucket GCS vers le répertoire actuel.

Paramètres
bucketPath Path : chemin d'accès au fichier dans le bucket GCS

Renvoie
CommandResult Résultat CommandResult de l'opération.

Génère
IOException

récupérer

public CommandResult pull (Path bucketPath, 
                File localFile)

Téléchargez un fichier ou un répertoire à partir d'un bucket GCS.

Paramètres
bucketPath Path : chemin d'accès au fichier dans le bucket GCS

localFile File : chemin d'accès local de destination.

Renvoie
CommandResult Résultat CommandResult de l'opération.

Génère
IOException

pullContents

public String pullContents (Path bucketPath)

Téléchargez un fichier à partir d'un bucket GCS et extrayez son contenu.

Paramètres
bucketPath Path : chemin d'accès au fichier dans le bucket GCS

Renvoie
String Contenu de la chaîne du fichier

Génère
IOException

transmettre

public CommandResult push (File localFile)

Importez un fichier ou un répertoire local dans un bucket GCS.

Paramètres
localFile File : fichier ou répertoire local

Renvoie
CommandResult Résultat CommandResult de l'opération.

Génère
IOException

transmettre

public CommandResult push (File localFile, 
                Path bucketPath)

Importez un fichier ou un répertoire local dans un bucket GCS avec un chemin d'accès spécifique.

Paramètres
localFile File : fichier ou répertoire local

bucketPath Path : chemin d'accès au fichier dans le bucket GCS

Renvoie
CommandResult Résultat CommandResult de l'opération.

Génère
IOException

pushString

public CommandResult pushString (String contents, 
                Path bucketPath)

Importer une chaîne dans un bucket GCS.

Paramètres
contents String : contenu du fichier, sous forme de chaîne

bucketPath Path : chemin d'accès au fichier dans le bucket GCS

Renvoie
CommandResult Résultat CommandResult de l'opération.

Génère
IOException

supprimer

public CommandResult remove (String pattern, 
                boolean force)

Supprimez un fichier ou un répertoire du bucket.

Paramètres
pattern String : fichier, répertoire ou modèle à supprimer.

force boolean : indique s'il faut ignorer les échecs et continuer en mode silencieux (aucune exception ne sera générée).

Renvoie
CommandResult

Génère
IOException

supprimer

public CommandResult remove (Path path, 
                boolean force)

Supprimez un fichier ou un répertoire du bucket.

Paramètres
path Path : chemin d'accès à supprimer

force boolean : indique si l'opération doit échouer si le fichier n'existe pas.

Renvoie
CommandResult

Génère
IOException

supprimer

public CommandResult remove (Path path)

Supprimez un fichier ou un répertoire du bucket.

Paramètres
path Path : chemin d'accès à supprimer

Renvoie
CommandResult

Génère
IOException

supprimer

public CommandResult remove (String pattern)

Supprimez un fichier ou un répertoire du bucket.

Paramètres
pattern String : fichier, répertoire ou modèle à supprimer.

Renvoie
CommandResult

Génère
IOException

removeBucket

public CommandResult removeBucket ()

Supprimer le bucket GCS

Renvoie
CommandResult

Génère
java.io.IOException
IOException

setAttempts

public void setAttempts (int attempts)

Paramètres
attempts int

setBotoConfig

public void setBotoConfig (String botoConfig)

Paramètres
botoConfig String

setBotoPath

public void setBotoPath (String botoPath)

Paramètres
botoPath String

setBucketName

public void setBucketName (String bucketName)

Paramètres
bucketName String

setNoClobber

public void setNoClobber (boolean noClobber)

Paramètres
noClobber boolean

setParallel

public void setParallel (boolean parallel)

Paramètres
parallel boolean

setRecursive

public void setRecursive (boolean recursive)

Paramètres
recursive boolean

setRetryInterval

public void setRetryInterval (long retryInterval)

Paramètres
retryInterval long

setTimeout

public void setTimeout (long timeout, 
                TimeUnit unit)

Paramètres
timeout long

unit TimeUnit

setTimeoutMs

public void setTimeoutMs (long timeout)

Paramètres
timeout long

stat

public GCSBucketUtil.GCSFileMetadata stat (Path bucketPath)

Obtenez l'état du fichier pour le chemin d'accès GCS.

Paramètres
bucketPath Path : chemin d'accès GCS

Renvoie
GCSBucketUtil.GCSFileMetadata GCSFileMetadata pour le chemin d'accès GCS

Génère
java.io.IOException
IOException

Méthodes protégées

getRunUtil

protected IRunUtil getRunUtil ()

Renvoie
IRunUtil