GCSFileDownloaderBase

public class GCSFileDownloaderBase
extends GCSCommon

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


Google Cloud Storage(GCS)からファイルをダウンロードするファイル ダウンローダー。

概要

定数

String GCS_APPROX_PREFIX

String GCS_PREFIX

フィールド

protected Boolean mCreateEmptyFile

パブリック コンストラクタ

GCSFileDownloaderBase()
GCSFileDownloaderBase(Boolean createEmptyFile)

パブリック メソッド

static File createTempFileForRemote(String remoteFilePath, File rootDir)

指定されたパスでダウンロードされたファイルを格納する一意のファイルを一時ディスクに作成します。

InputStream downloadFile(String bucketName, String filename)

GCS バケット ファイルからファイルをダウンロードします。

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

指定されたファイル名がフォルダかどうかを確認します。

String sanitizeDirectoryName(String name)

保護されたメソッド

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)

定数

GCS_APPROX_PREFIX

public static final String GCS_APPROX_PREFIX

定数値: "gs:/"

GCS_PREFIX

public static final String GCS_PREFIX

定数値: "gs://"

フィールド

mCreateEmptyFile

protected Boolean mCreateEmptyFile

パブリック コンストラクタ

GCSFileDownloaderBase

public GCSFileDownloaderBase ()

GCSFileDownloaderBase

public GCSFileDownloaderBase (Boolean createEmptyFile)

パラメータ
createEmptyFile Boolean

パブリック メソッド

createTempFileForRemote

public static File createTempFileForRemote (String remoteFilePath, 
                File rootDir)

指定されたパスでダウンロードされたファイルを格納する一意のファイルを一時ディスクに作成します。

パスのベース ファイル名に基づいてファイル名を構築します

パラメータ
remoteFilePath String: 名前の作成元となるリモートパス

rootDir File

戻り値
File

downloadFile

public InputStream downloadFile (String bucketName, 
                String filename)

GCS バケット ファイルからファイルをダウンロードします。

パラメータ
bucketName String: GCS バケット名

filename String: ファイル名

戻り値
InputStream ERROR(/InputStream)(ファイルの内容)。

downloadFile

public void downloadFile (String remotePath, 
                File destFile)

パラメータ
remotePath String

destFile File

downloadFile

public File downloadFile (String remoteFilePath)

パラメータ
remoteFilePath String

戻り値
File

getRemoteFileMetaData

public StorageObject getRemoteFileMetaData (String bucketName, 
                String remoteFilename)

パラメータ
bucketName String

remoteFilename String

戻り値
StorageObject

isRemoteFolder

public boolean isRemoteFolder (String bucketName, 
                String filename)

指定されたファイル名がフォルダかどうかを確認します。

gcs には次の 2 種類のフォルダがあります。1. UI から明示的に作成された。フォルダはサイズ 0 のテキスト ファイル(オブジェクト)です。2. ファイルをアップロードすると、その親フォルダがすべて作成されますが、これらのフォルダは gcs に存在しません(オブジェクトではありません)。この関数はどちらの場合でも機能します。ただし、サイズが 0 のフォルダをダウンロードしようとすべきではありません。

パラメータ
bucketName String: GCS バケット名です。

filename String: バケットの相対パス。

戻り値
boolean ファイル名がフォルダの場合は true、それ以外の場合は false。

sanitizeDirectoryName

public String sanitizeDirectoryName (String name)

パラメータ
name String

戻り値
String

保護されたメソッド

createTempFile

protected File createTempFile (String remoteFilePath, 
                File rootDir)

パラメータ
remoteFilePath String

rootDir File

戻り値
File

downloadFile

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

パラメータ
bucketName String

remoteFilename String

localFile File

getStorage

protected Storage getStorage ()

戻り値
Storage

listRemoteFilesUnderFolder

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

パラメータ
bucketName String

folder String

subFiles

subFolders

parseGcsPath

protected String[] parseGcsPath (String remotePath)

パラメータ
remotePath String

戻り値
String[]