GCSFileDownloaderBase

public class GCSFileDownloaderBase
extends GCSCommon

java.lang.Object
   ↳ com.android.tradefed.util.gcs.GCSCommon
     ↳ com.android.tradefed.util.gcs.GCSFileDownloaderBase


Downloader di file per scaricare file da Google Cloud Storage (GCS).

Riepilogo

Costanti

String GCS_APPROX_PREFIX

String GCS_PREFIX

Campi

protected Boolean mCreateEmptyFile

Costruttori pubblici

GCSFileDownloaderBase()
GCSFileDownloaderBase(Boolean createEmptyFile)

Metodi pubblici

static File createTempFileForRemote(String remoteFilePath, File rootDir)

Crea un file univoco sul disco temporaneo per ospitare il file scaricato con il percorso specificato.

InputStream downloadFile(String bucketName, String filename)

Scarica un file da un file del bucket GCS.

void downloadFile(String remotePath, File destFile)
File downloadFile(String remoteFilePath)
StorageObject getRemoteFileMetaData(String bucketName, String remoteFilename)
boolean isRemoteFolder(String bucketName, String filename)

Controlla se il nome file specificato è una cartella o meno.

String sanitizeDirectoryName(String name)

Metodi protetti

File createTempFile(String remoteFilePath, File rootDir)
void downloadFile(String bucketName, String remoteFilename, File localFile)
Storage getStorage()
void listRemoteFilesUnderFolder(String bucketName, String folder, subFiles, subFolders)
String[] parseGcsPath(String remotePath)

Costanti

GCS_APPROX_PREFIX

public static final String GCS_APPROX_PREFIX

Valore costante: "gs:/"

GCS_PREFIX

public static final String GCS_PREFIX

Valore costante: "gs://"

Campi

mCreateEmptyFile

protected Boolean mCreateEmptyFile

Costruttori pubblici

GCSFileDownloaderBase

public GCSFileDownloaderBase ()

GCSFileDownloaderBase

public GCSFileDownloaderBase (Boolean createEmptyFile)

Parametri
createEmptyFile Boolean

Metodi pubblici

createTempFileForRemote

public static File createTempFileForRemote (String remoteFilePath, 
                File rootDir)

Crea un file univoco sul disco temporaneo per ospitare il file scaricato con il percorso specificato.

Costruisce il nome del file in base al nome del file di base dal percorso

Parametri
remoteFilePath String: il percorso remoto da cui costruire il nome

rootDir File

Ritorni
File

downloadFile

public InputStream downloadFile (String bucketName, 
                String filename)

Scarica un file da un file del bucket GCS.

Parametri
bucketName String: nome del bucket GCS

filename String: il nome del file

Ritorni
InputStream ERROR(/InputStream) con i contenuti del file.

downloadFile

public void downloadFile (String remotePath, 
                File destFile)

Parametri
remotePath String

destFile File

downloadFile

public File downloadFile (String remoteFilePath)

Parametri
remoteFilePath String

Ritorni
File

getRemoteFileMetaData

public StorageObject getRemoteFileMetaData (String bucketName, 
                String remoteFilename)

Parametri
bucketName String

remoteFilename String

Ritorni
StorageObject

isRemoteFolder

public boolean isRemoteFolder (String bucketName, 
                String filename)

Controlla se il nome file specificato è una cartella o meno.

Esistono due tipi di cartelle in GCS: 1. Creato esplicitamente dall'interfaccia utente. La cartella è un file di testo di dimensione 0 (è un oggetto). 2. Quando carichi un file, vengono create tutte le relative cartelle principali, ma queste cartelle non esistono (non sono oggetti) in GCS. Questa funzione funziona per entrambi i casi. Ma non dobbiamo provare a scaricare le cartelle di dimensioni 0.

Parametri
bucketName String: è il nome del bucket GCS.

filename String: è il percorso relativo del bucket.

Ritorni
boolean true se il nome file è una cartella, altrimenti false.

sanitizeDirectoryName

public String sanitizeDirectoryName (String name)

Parametri
name String

Ritorni
String

Metodi protetti

createTempFile

protected File createTempFile (String remoteFilePath, 
                File rootDir)

Parametri
remoteFilePath String

rootDir File

Ritorni
File

downloadFile

protected void downloadFile (String bucketName, 
                String remoteFilename, 
                File localFile)

Parametri
bucketName String

remoteFilename String

localFile File

getStorage

protected Storage getStorage ()

Ritorni
Storage

listRemoteFilesUnderFolder

protected void listRemoteFilesUnderFolder (String bucketName, 
                String folder, 
                 subFiles, 
                 subFolders)

Parametri
bucketName String

folder String

subFiles

subFolders

parseGcsPath

protected String[] parseGcsPath (String remotePath)

Parametri
remotePath String

Ritorni
String[]