GCSFileDownloaderBase

public class GCSFileDownloaderBase
extends GCSCommon

java.lang.Object
   ↳ com.android.tradefed.util.gcs.GCSCommon (link em inglês)
     ↳ com.android.tradefed.util.gcs.GCSFileDownloaderBase


Ferramenta de download para salvar arquivos do Google Cloud Storage (GCS).

Resumo

Campos

public static final String GCS_APPROX_PREFIX

public static final String GCS_PREFIX

protected Boolean mCreateEmptyFile

Construtores públicos

GCSFileDownloaderBase(Boolean createEmptyFile)
GCSFileDownloaderBase()

Métodos públicos

static File createTempFileForRemote(String remoteFilePath, File rootDir)

Cria um arquivo exclusivo em disco temporário para abrigar o arquivo transferido por download com determinado caminho.

InputStream downloadFile(String bucketName, String filename)

Fazer o download de um arquivo de bucket do GCS.

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

Verificar se o nome do arquivo é uma pasta ou não.

String sanitizeDirectoryName(String name)

Métodos protegidos

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)

Campos

GCS_APPROX_PREFIX

public static final String GCS_APPROX_PREFIX

GCS_PREFIX

public static final String GCS_PREFIX

mCriarArquivoVazio

protected Boolean mCreateEmptyFile

Construtores públicos

GCSFileDownloaderBase

public GCSFileDownloaderBase (Boolean createEmptyFile)

Parâmetros
createEmptyFile Boolean

GCSFileDownloaderBase

public GCSFileDownloaderBase ()

Métodos públicos

createTempFileForRemote

public static File createTempFileForRemote (String remoteFilePath, 
                File rootDir)

Cria um arquivo exclusivo em disco temporário para abrigar o arquivo transferido por download com o caminho especificado.

Cria o nome do arquivo com base no nome do arquivo de base do caminho

Parâmetros
remoteFilePath String: o caminho remoto para criar o nome.

rootDir File

Retorna
File

Baixar o Arquivo

public InputStream downloadFile (String bucketName, 
                String filename)

Fazer o download de um arquivo de bucket do GCS.

Parâmetros
bucketName String: nome do bucket do GCS

filename String: o nome do arquivo.

Retorna
InputStream ERROR(/InputStream) pelo conteúdo do arquivo.

Baixar o Arquivo

public void downloadFile (String remotePath, 
                File destFile)

Parâmetros
remotePath String

destFile File

Baixar o Arquivo

public File downloadFile (String remoteFilePath)

Parâmetros
remoteFilePath String

Retorna
File

getRemoteFileMetaData

public StorageObject getRemoteFileMetaData (String bucketName, 
                String remoteFilename)

Parâmetros
bucketName String

remoteFilename String

Retorna
StorageObject

isRemoteFolder

public boolean isRemoteFolder (String bucketName, 
                String filename)

Verificar se o nome do arquivo é uma pasta ou não.

Há dois tipos de pastas no GCS: 1. Criado explicitamente da interface. A pasta tem tamanho 0 arquivo de texto (é um objeto). 2. Ao fazer o upload de um arquivo, todas as pastas principais dele são criadas, mas essas pastas não existem (não são objetos) no gcs. Essa função funciona para os dois casos. Mas não devemos tentar baixar as pastas de tamanho 0.

Parâmetros
bucketName String: é o nome do bucket do GCS.

filename String: é o caminho relativo para o bucket.

Retorna
boolean verdadeiro se o nome do arquivo for uma pasta; caso contrário, falso.

sanitizeDirectoryName

public String sanitizeDirectoryName (String name)

Parâmetros
name String

Retorna
String

Métodos protegidos

criarArquivoTemp.

protected File createTempFile (String remoteFilePath, 
                File rootDir)

Parâmetros
remoteFilePath String

rootDir File

Retorna
File

Baixar o Arquivo

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

Parâmetros
bucketName String

remoteFilename String

localFile File

getStorage

protected Storage getStorage ()

Retorna
Storage

listRemoteFilesUnderFolder

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

Parâmetros
bucketName String

folder String

subFiles

subFolders

parseGcsPath

protected String[] parseGcsPath (String remotePath)

Parâmetros
remotePath String

Retorna
String[]