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

‫constructors ציבוריים

GCSFileDownloaderBase()
GCSFileDownloaderBase(Boolean createEmptyFile)

‫methods ציבוריים

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

‫constructors ציבוריים

GCSFileDownloaderBase

public GCSFileDownloaderBase ()

GCSFileDownloaderBase

public GCSFileDownloaderBase (Boolean createEmptyFile)

פרמטרים
createEmptyFile Boolean

‫methods ציבוריים

createTempFileForRemote

public static File createTempFileForRemote (String remoteFilePath, 
                File rootDir)

יוצר קובץ ייחודי בדיסק זמני כדי לאחסן את הקובץ שהורד עם הנתיב שצוין.

יוצר את שם הקובץ על סמך שם הקובץ הבסיסי מהנתיב

פרמטרים
remoteFilePath String: הנתיב המרוחק שממנו ייבנה השם

rootDir File

החזרות
File

הקפצת הודעות שגיאה (throw)
Exception

downloadFile

public InputStream downloadFile (String bucketName, 
                String filename)

הורדת קובץ מקובץ בקטגוריה של GCS.

פרמטרים
bucketName String: שם קטגוריית GCS

filename String: שם הקובץ

החזרות
InputStream InputStream עם תוכן הקובץ.

הקפצת הודעות שגיאה (throw)
IOException

downloadFile

public void downloadFile (String remotePath, 
                File destFile)

פרמטרים
remotePath String

destFile File

הקפצת הודעות שגיאה (throw)
Exception

downloadFile

public File downloadFile (String remoteFilePath)

פרמטרים
remoteFilePath String

החזרות
File

הקפצת הודעות שגיאה (throw)
Exception

getRemoteFileMetaData

public StorageObject getRemoteFileMetaData (String bucketName, 
                String remoteFilename)

פרמטרים
bucketName String

remoteFilename String

החזרות
StorageObject

הקפצת הודעות שגיאה (throw)
IOException

isRemoteFolder

public boolean isRemoteFolder (String bucketName, 
                String filename)

בודקים אם שם הקובץ שצוין הוא תיקייה או לא.

יש 2 סוגים של תיקיות ב-GCS: 1. נוצר באופן מפורש מממשק המשתמש. התיקייה היא קובץ טקסט בגודל 0 (זהו אובייקט). 2. כשמעלים קובץ, כל תיקיות ההורה שלו נוצרות, אבל התיקיות האלה לא קיימות (לא אובייקטים) ב-GCS. הפונקציה הזו פועלת בשני המקרים. אבל לא כדאי לנסות להוריד תיקיות בגודל 0. אם ההרשאה נדחתה, נניח שמדובר בקובץ כדי למנוע שיבוש בהרצה.

פרמטרים
bucketName String: שם קטגוריית ה-GCS.

filename String: הנתיב היחסי לקטגוריה.

החזרות
boolean הערך הוא true אם שם הקובץ הוא תיקייה, אחרת הערך הוא false.

הקפצת הודעות שגיאה (throw)
IOException

sanitizeDirectoryName

public String sanitizeDirectoryName (String name)

פרמטרים
name String

החזרות
String

שיטות מוגנות

createTempFile

protected File createTempFile (String remoteFilePath, 
                File rootDir)

פרמטרים
remoteFilePath String

rootDir File

החזרות
File

הקפצת הודעות שגיאה (throw)
Exception

downloadFile

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

פרמטרים
bucketName String

remoteFilename String

localFile File

הקפצת הודעות שגיאה (throw)
Exception

getStorage

protected Storage getStorage ()

החזרות
Storage

הקפצת הודעות שגיאה (throw)
IOException

listRemoteFilesUnderFolder

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

פרמטרים
bucketName String

folder String

subFiles List

subFolders List

הקפצת הודעות שגיאה (throw)
IOException

parseGcsPath

protected String[] parseGcsPath (String remotePath)

פרמטרים
remotePath String

החזרות
String[]

הקפצת הודעות שגיאה (throw)
Exception