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, List<StorageObject> subFiles, List<String> 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

ส่ง
Exception

downloadFile

public InputStream downloadFile (String bucketName, 
                String filename)

ดาวน์โหลดไฟล์จากไฟล์ในที่เก็บข้อมูล GCS

พารามิเตอร์
bucketName String: ชื่อ Bucket ของ GCS

filename String: ชื่อไฟล์

การคืนสินค้า
InputStream InputStream พร้อมเนื้อหาของไฟล์

ส่ง
IOException

downloadFile

public void downloadFile (String remotePath, 
                File destFile)

พารามิเตอร์
remotePath String

destFile File

ส่ง
Exception

downloadFile

public File downloadFile (String remoteFilePath)

พารามิเตอร์
remoteFilePath String

การคืนสินค้า
File

ส่ง
Exception

getRemoteFileMetaData

public StorageObject getRemoteFileMetaData (String bucketName, 
                String remoteFilename)

พารามิเตอร์
bucketName String

remoteFilename String

การคืนสินค้า
StorageObject

ส่ง
IOException

isRemoteFolder

public boolean isRemoteFolder (String bucketName, 
                String filename)

ตรวจสอบว่าชื่อไฟล์ที่ระบุเป็นโฟลเดอร์หรือไม่

โฟลเดอร์ใน GCS มี 2 ประเภท ได้แก่ 1. สร้างจาก UI โดยเฉพาะ โฟลเดอร์เป็นไฟล์ข้อความขนาด 0 (เป็นออบเจ็กต์) 2. เมื่ออัปโหลดไฟล์ ระบบจะสร้างโฟลเดอร์ระดับบนทั้งหมดของไฟล์นั้น แต่โฟลเดอร์เหล่านี้จะไม่มีอยู่ (ไม่ใช่ออบเจ็กต์) ใน GCS ฟังก์ชันนี้ใช้ได้กับทั้ง 2 กรณี แต่ เราไม่ควรพยายามดาวน์โหลดโฟลเดอร์ที่มีขนาดเป็น 0 ในกรณีที่สิทธิ์ถูกปฏิเสธ เราจะถือว่าเป็นไฟล์เพื่อหลีกเลี่ยงการหยุดการ ดำเนินการ

พารามิเตอร์
bucketName String: คือชื่อ Bucket ของ GCS

filename String: คือเส้นทางที่เกี่ยวข้องไปยังที่เก็บข้อมูล

การคืนสินค้า
boolean เป็นจริงหากชื่อไฟล์เป็นโฟลเดอร์ มิเช่นนั้นจะเป็นเท็จ

ส่ง
IOException

sanitizeDirectoryName

public String sanitizeDirectoryName (String name)

พารามิเตอร์
name String

การคืนสินค้า
String

วิธีการที่ได้รับการป้องกัน

createTempFile

protected File createTempFile (String remoteFilePath, 
                File rootDir)

พารามิเตอร์
remoteFilePath String

rootDir File

การคืนสินค้า
File

ส่ง
Exception

downloadFile

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

พารามิเตอร์
bucketName String

remoteFilename String

localFile File

ส่ง
Exception

getStorage

protected Storage getStorage ()

การคืนสินค้า
Storage

ส่ง
IOException

listRemoteFilesUnderFolder

protected void listRemoteFilesUnderFolder (String bucketName, 
                String folder, 
                List<StorageObject> subFiles, 
                List<String> subFolders)

พารามิเตอร์
bucketName String

folder String

subFiles List

subFolders List

ส่ง
IOException

parseGcsPath

protected String[] parseGcsPath (String remotePath)

พารามิเตอร์
remotePath String

การคืนสินค้า
String[]

ส่ง
Exception