Gestionnaire de fichiers pour télécharger et télécharger des fichiers depuis Google Cloud Storage (GCS).
Cette classe ne doit PAS être utilisée dans le cadre d'un test (c'est-à-dire IRemoteTest). Ceci est obsolète, veuillez utiliser GCSFileDownloader
à la place.
Classes imbriquées |
---|
class | GCSBucketUtil.GCSFileMetadata Wrapper simple pour les informations de fichier dans GCS. |
Constructeurs publics
GCSBucketUtil
public GCSBucketUtil (String bucketName)
Paramètres |
---|
bucketName | String |
Méthodes publiques
copie
public CommandResult copy (String source,
String dest)
Copiez un fichier ou un répertoire vers ou depuis le compartiment.
Paramètres |
---|
source | String : fichier source ou modèle |
dest | String : fichier ou modèle de destination |
getAttempts
public int getAttempts ()
getBotoConfig
public String getBotoConfig ()
getBotoPath
public String getBotoPath ()
getBucketName
public String getBucketName ()
getNoClobber
public boolean getNoClobber ()
obtenirParallèle
public boolean getParallel ()
getRecursive
public boolean getRecursive ()
getRetryInterval
public long getRetryInterval ()
getTimeout
public long getTimeout ()
estFichier
public boolean isFile (String path)
Vérifier qu'un fichier GCS est un fichier ou non un fichier (un dossier).
Si le nom du fichier se termine par '/', il s'agit d'un dossier. gsutil ls gs://filename doit renvoyer gs://filename s'il s'agit d'un fichier. gsutil ls gs://nom du dossier doit renvoyer les fichiers dans le dossier s'il y a des fichiers dans le dossier. Et il renverra gs://folder/ s'il n'y a pas de fichiers dans le dossier.
Paramètres |
---|
path | String : le chemin relatif au bucket. |
Retour |
---|
boolean | c'est un fichier ou pas un fichier. |
ls
public ls (Path bucketPath)
Répertorier les fichiers sous un chemin GCS.
Paramètres |
---|
bucketPath | Path : le chemin GCS |
Retour |
---|
| une liste de ERROR(/String) s qui sont des fichiers sous le chemin GCS |
marqueBucket
public CommandResult makeBucket (String projectId)
Fabriquez le seau GCS.
Paramètres |
---|
projectId | String |
hachage md5
public String md5Hash (File localFile)
Calculez le hachage md5 pour le fichier local.
Paramètres |
---|
localFile | File : un fichier local |
Retour |
---|
String | le hachage md5 pour le fichier local. |
tirer
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 de destination local |
tirer
public CommandResult pull (Path bucketPath)
Téléchargez un fichier ou un répertoire d'un bucket GCS vers le répertoire actuel.
Paramètres |
---|
bucketPath | Path : chemin d'accès au fichier dans le bucket GCS |
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 |
Retour |
---|
String | Contenu de la chaîne du fichier |
pousser
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 |
pousser
public CommandResult push (File localFile,
Path bucketPath)
Importez un fichier ou un répertoire local dans un bucket GCS avec un chemin spécifique.
Paramètres |
---|
localFile | File : Fichier ou répertoire local |
bucketPath | Path : chemin d'accès au fichier dans le bucket GCS |
pushString
public CommandResult pushString (String contents,
Path bucketPath)
Importez 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 |
retirer
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 : s'il faut ignorer les échecs et continuer en silence (ne lancera pas) |
retirer
public CommandResult remove (Path path,
boolean force)
Supprimez un fichier ou un répertoire du bucket.
Paramètres |
---|
path | Path : Chemin à supprimer |
force | boolean : échec si le fichier n'existe pas |
retirer
public CommandResult remove (Path path)
Supprimez un fichier ou un répertoire du bucket.
Paramètres |
---|
path | Path : Chemin à supprimer |
retirer
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. |
removeBucket
public CommandResult removeBucket ()
Supprimer le bucket GCS
setAttempts
public void setAttempts (int attempts)
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 |
setRécursif
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)
statistique
public GCSBucketUtil.GCSFileMetadata stat (Path bucketPath)
Obtenez l'état du fichier pour le chemin GCS.
Paramètres |
---|
bucketPath | Path : le chemin GCS |
Méthodes protégées
getRunUtil
protected IRunUtil getRunUtil ()
Le contenu et les exemples de code de cette page sont soumis aux licences décrites dans la Licence de contenu. Java et OpenJDK sont des marques ou des marques déposées d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2023/03/30 (UTC).
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Il n'y a pas l'information dont j'ai besoin"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Trop compliqué/Trop d'étapes"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Obsolète"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Problème de traduction"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Mauvais exemple/Erreur de code"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Autre"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Facile à comprendre"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"J'ai pu résoudre mon problème"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Autre"
}]