GCSFileDownloaderBase

public class GCSFileDownloaderBase
extends GCSCommon

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


Trình tải tệp xuống để tải tệp xuống từ Google Cloud Storage (GCS).

Tóm tắt

Hằng số

String GCS_APPROX_PREFIX

String GCS_PREFIX

Trường

protected Boolean mCreateEmptyFile

Hàm khởi tạo công khai

GCSFileDownloaderBase()
GCSFileDownloaderBase(Boolean createEmptyFile)

Phương thức công khai

static File createTempFileForRemote(String remoteFilePath, File rootDir)

Tạo một tệp duy nhất trên ổ đĩa tạm thời để lưu trữ tệp đã tải xuống theo đường dẫn đã cho.

InputStream downloadFile(String bucketName, String filename)

Tải một tệp xuống từ tệp bộ chứa GCS.

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

Kiểm tra xem tên tệp đã cho có phải là thư mục hay không.

String sanitizeDirectoryName(String name)

Phương thức được bảo vệ

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)

Hằng số

GCS_APPROX_PREFIX

public static final String GCS_APPROX_PREFIX

Giá trị không đổi: "gs:/"

GCS_PREFIX

public static final String GCS_PREFIX

Giá trị không đổi: "gs://"

Trường

mCreateEmptyFile

protected Boolean mCreateEmptyFile

Hàm khởi tạo công khai

GCSFileDownloaderBase

public GCSFileDownloaderBase ()

GCSFileDownloaderBase

public GCSFileDownloaderBase (Boolean createEmptyFile)

Tham số
createEmptyFile Boolean

Phương thức công khai

createTempFileForRemote

public static File createTempFileForRemote (String remoteFilePath, 
                File rootDir)

Tạo một tệp duy nhất trên ổ đĩa tạm thời để lưu trữ tệp đã tải xuống theo đường dẫn đã cho.

Tạo tên tệp dựa trên tên tệp cơ sở từ đường dẫn

Tham số
remoteFilePath String: đường dẫn từ xa để tạo tên

rootDir File

Giá trị trả về
File

downloadFile

public InputStream downloadFile (String bucketName, 
                String filename)

Tải một tệp xuống từ tệp bộ chứa GCS.

Tham số
bucketName String: Tên bộ chứa GCS

filename String: tên tệp

Giá trị trả về
InputStream ERROR(/InputStream) có nội dung tệp.

downloadFile

public void downloadFile (String remotePath, 
                File destFile)

Tham số
remotePath String

destFile File

downloadFile

public File downloadFile (String remoteFilePath)

Tham số
remoteFilePath String

Giá trị trả về
File

getRemoteFileMetaData

public StorageObject getRemoteFileMetaData (String bucketName, 
                String remoteFilename)

Tham số
bucketName String

remoteFilename String

Giá trị trả về
StorageObject

isRemoteFolder

public boolean isRemoteFolder (String bucketName, 
                String filename)

Kiểm tra xem tên tệp đã cho có phải là thư mục hay không.

Có 2 loại thư mục trong gcs: 1. Được tạo rõ ràng từ giao diện người dùng. Thư mục này là một tệp văn bản có kích thước 0 (đây là một đối tượng). 2. Khi bạn tải một tệp lên, tất cả các thư mục mẹ của tệp đó sẽ được tạo, nhưng những thư mục này không tồn tại (không phải là đối tượng) trong gcs. Hàm này hoạt động cho cả hai trường hợp. Nhưng chúng ta không nên cố gắng tải các thư mục có kích thước bằng 0 xuống.

Tham số
bucketName String: là tên bộ chứa gcs.

filename String: là đường dẫn tương đối đến nhóm.

Giá trị trả về
boolean true nếu tên tệp là một thư mục, ngược lại là false.

sanitizeDirectoryName

public String sanitizeDirectoryName (String name)

Tham số
name String

Giá trị trả về
String

Phương thức được bảo vệ

createTempFile

protected File createTempFile (String remoteFilePath, 
                File rootDir)

Tham số
remoteFilePath String

rootDir File

Giá trị trả về
File

downloadFile

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

Tham số
bucketName String

remoteFilename String

localFile File

getStorage

protected Storage getStorage ()

Giá trị trả về
Storage

listRemoteFilesUnderFolder

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

Tham số
bucketName String

folder String

subFiles

subFolders

parseGcsPath

protected String[] parseGcsPath (String remotePath)

Tham số
remotePath String

Trả về
String[]