GCSBucketUtil
public
class
GCSBucketUtil
extends Object
| java.lang.Object | |
| ↳ | com.android.tradefed.util.GCSBucketUtil |
เครื่องมือจัดการไฟล์สำหรับดาวน์โหลดและอัปโหลดไฟล์จาก Google Cloud Storage (GCS)
ไม่ควรใช้คลาสนี้จากขอบเขตการทดสอบ (เช่น IRemoteTest) การตั้งค่านี้เลิกใช้งานแล้ว โปรดใช้ GCSFileDownloader แทน
สรุป
ชั้นเรียนที่ซ้อนกัน | |
|---|---|
class |
GCSBucketUtil.GCSFileMetadata
Wrapper ง่ายๆ สำหรับข้อมูลไฟล์ใน GCS |
ตัวสร้างแบบสาธารณะ | |
|---|---|
GCSBucketUtil(String bucketName)
|
|
เมธอดสาธารณะ | |
|---|---|
CommandResult
|
copy(String source, String dest)
คัดลอกไฟล์หรือไดเรกทอรีไปยังหรือจากที่เก็บข้อมูล |
int
|
getAttempts()
|
String
|
getBotoConfig()
|
String
|
getBotoPath()
|
String
|
getBucketName()
|
boolean
|
getNoClobber()
|
boolean
|
getParallel()
|
boolean
|
getRecursive()
|
long
|
getRetryInterval()
|
long
|
getTimeout()
|
boolean
|
isFile(String path)
ตรวจสอบว่าไฟล์ GCS เป็นไฟล์หรือไม่ใช่ไฟล์ (โฟลเดอร์) |
|
ls(Path bucketPath)
แสดงรายการไฟล์ในเส้นทาง GCS |
CommandResult
|
makeBucket(String projectId)
สร้างที่เก็บข้อมูล GCS |
String
|
md5Hash(File localFile)
คํานวณแฮช MD5 สําหรับไฟล์ในเครื่อง |
CommandResult
|
pull(Path bucketPath, File localFile)
ดาวน์โหลดไฟล์หรือไดเรกทอรีจากที่เก็บข้อมูล GCS |
CommandResult
|
pull(Path bucketPath)
ดาวน์โหลดไฟล์หรือไดเรกทอรีจากที่เก็บข้อมูล GCS ไปยังไดเรกทอรีปัจจุบัน |
String
|
pullContents(Path bucketPath)
ดาวน์โหลดไฟล์จากที่เก็บข้อมูล GCS และดึงเนื้อหาของไฟล์ |
CommandResult
|
push(File localFile)
อัปโหลดไฟล์หรือไดเรกทอรีในเครื่องไปยังที่เก็บข้อมูล GCS |
CommandResult
|
push(File localFile, Path bucketPath)
อัปโหลดไฟล์หรือไดเรกทอรีในเครื่องไปยังที่เก็บข้อมูล GCS ที่มีเส้นทางที่เฉพาะเจาะจง |
CommandResult
|
pushString(String contents, Path bucketPath)
อัปโหลดสตริงไปยังที่เก็บข้อมูล GCS |
CommandResult
|
remove(Path path)
นำไฟล์หรือไดเรกทอรีออกจากที่เก็บข้อมูล |
CommandResult
|
remove(Path path, boolean force)
นำไฟล์หรือไดเรกทอรีออกจากที่เก็บข้อมูล |
CommandResult
|
removeBucket()
นำที่เก็บข้อมูล GCS ออก |
void
|
setAttempts(int attempts)
|
void
|
setBotoConfig(String botoConfig)
|
void
|
setBotoPath(String botoPath)
|
void
|
setBucketName(String bucketName)
|
void
|
setNoClobber(boolean noClobber)
|
void
|
setParallel(boolean parallel)
|
void
|
setRecursive(boolean recursive)
|
void
|
setRetryInterval(long retryInterval)
|
void
|
setTimeout(long timeout, TimeUnit unit)
|
void
|
setTimeoutMs(long timeout)
|
GCSBucketUtil.GCSFileMetadata
|
stat(Path bucketPath)
รับสถานะของไฟล์สำหรับเส้นทาง GCS |
วิธีการที่มีการป้องกัน | |
|---|---|
IRunUtil
|
getRunUtil()
|
ตัวสร้างแบบสาธารณะ
GCSBucketUtil
public GCSBucketUtil (String bucketName)
| พารามิเตอร์ | |
|---|---|
bucketName |
String |
เมธอดสาธารณะ
คัดลอก
public CommandResult copy (String source, String dest)
คัดลอกไฟล์หรือไดเรกทอรีไปยังหรือจากที่เก็บข้อมูล
| พารามิเตอร์ | |
|---|---|
source |
String: ไฟล์ต้นฉบับหรือรูปแบบ |
dest |
String: ไฟล์หรือรูปแบบปลายทาง |
| คิกรีเทิร์น | |
|---|---|
CommandResult |
CommandResult ผลลัพธ์ของการดำเนินการ |
getAttempts
public int getAttempts ()
| คิกรีเทิร์น | |
|---|---|
int |
|
getBotoConfig
public String getBotoConfig ()
| คิกรีเทิร์น | |
|---|---|
String |
|
getBotoPath
public String getBotoPath ()
| คิกรีเทิร์น | |
|---|---|
String |
|
getBucketName
public String getBucketName ()
| คิกรีเทิร์น | |
|---|---|
String |
|
getNoClobber
public boolean getNoClobber ()
| คิกรีเทิร์น | |
|---|---|
boolean |
|
getParallel
public boolean getParallel ()
| คิกรีเทิร์น | |
|---|---|
boolean |
|
getRecursive
public boolean getRecursive ()
| คิกรีเทิร์น | |
|---|---|
boolean |
|
getRetryInterval
public long getRetryInterval ()
| คิกรีเทิร์น | |
|---|---|
long |
|
getTimeout
public long getTimeout ()
| คิกรีเทิร์น | |
|---|---|
long |
|
isFile
public boolean isFile (String path)
ตรวจสอบว่าไฟล์ GCS เป็นไฟล์หรือไม่ใช่ไฟล์ (โฟลเดอร์)
หากชื่อไฟล์ลงท้ายด้วย "/" แสดงว่าเป็นโฟลเดอร์ gsutil ls gs://filename ควรแสดงผล gs://filename หากเป็นไฟล์ gsutil ls gs://folder name ควรแสดงไฟล์ในโฟลเดอร์ หากมีไฟล์ในโฟลเดอร์ และจะแสดงผล gs://folder/ หากไม่มีไฟล์ในโฟลเดอร์
| พารามิเตอร์ | |
|---|---|
path |
String: เส้นทางที่สัมพันธ์กับที่เก็บข้อมูล.. |
| คิกรีเทิร์น | |
|---|---|
boolean |
ไฟล์หรือไม่เป็นไฟล์ |
| การโยน | |
|---|---|
|
IOException |
ls
publicls (Path bucketPath)
แสดงรายการไฟล์ในเส้นทาง GCS
| พารามิเตอร์ | |
|---|---|
bucketPath |
Path: เส้นทาง GCS |
| คิกรีเทิร์น | |
|---|---|
|
รายการ String ที่คือไฟล์ในเส้นทาง GCS |
| การโยน | |
|---|---|
|
IOException |
makeBucket
public CommandResult makeBucket (String projectId)
สร้างที่เก็บข้อมูล GCS
| พารามิเตอร์ | |
|---|---|
projectId |
String |
| คิกรีเทิร์น | |
|---|---|
CommandResult |
CommandResult ผลลัพธ์ของการดำเนินการ |
| การโยน | |
|---|---|
|
IOException |
md5Hash
public String md5Hash (File localFile)
คํานวณแฮช MD5 สําหรับไฟล์ในเครื่อง
| พารามิเตอร์ | |
|---|---|
localFile |
File: ไฟล์ในเครื่อง |
| คิกรีเทิร์น | |
|---|---|
String |
แฮช MD5 ของไฟล์ในเครื่อง |
| การโยน | |
|---|---|
|
IOException |
ดึง
public CommandResult pull (Path bucketPath, File localFile)
ดาวน์โหลดไฟล์หรือไดเรกทอรีจากที่เก็บข้อมูล GCS
| พารามิเตอร์ | |
|---|---|
bucketPath |
Path: เส้นทางไฟล์ในที่เก็บข้อมูล GCS |
localFile |
File: เส้นทางปลายทางภายใน |
| คิกรีเทิร์น | |
|---|---|
CommandResult |
CommandResult ผลลัพธ์ของการดำเนินการ |
ดึง
public CommandResult pull (Path bucketPath)
ดาวน์โหลดไฟล์หรือไดเรกทอรีจากที่เก็บข้อมูล GCS ไปยังไดเรกทอรีปัจจุบัน
| พารามิเตอร์ | |
|---|---|
bucketPath |
Path: เส้นทางไฟล์ในที่เก็บข้อมูล GCS |
| คิกรีเทิร์น | |
|---|---|
CommandResult |
CommandResult ผลลัพธ์ของการดำเนินการ |
pullContents
public String pullContents (Path bucketPath)
ดาวน์โหลดไฟล์จากที่เก็บข้อมูล GCS และดึงเนื้อหาของไฟล์
| พารามิเตอร์ | |
|---|---|
bucketPath |
Path: เส้นทางไฟล์ในที่เก็บข้อมูล GCS |
| คิกรีเทิร์น | |
|---|---|
String |
เนื้อหาสตริงของไฟล์ |
กด
public CommandResult push (File localFile)
อัปโหลดไฟล์หรือไดเรกทอรีในเครื่องไปยังที่เก็บข้อมูล GCS
| พารามิเตอร์ | |
|---|---|
localFile |
File: ไฟล์หรือไดเรกทอรีในเครื่อง |
| คิกรีเทิร์น | |
|---|---|
CommandResult |
CommandResult ผลลัพธ์ของการดำเนินการ |
กด
public CommandResult push (File localFile, Path bucketPath)
อัปโหลดไฟล์หรือไดเรกทอรีในเครื่องไปยังที่เก็บข้อมูล GCS ที่มีเส้นทางที่เฉพาะเจาะจง
| พารามิเตอร์ | |
|---|---|
localFile |
File: ไฟล์หรือไดเรกทอรีในเครื่อง |
bucketPath |
Path: เส้นทางไฟล์ในที่เก็บข้อมูล GCS |
| คิกรีเทิร์น | |
|---|---|
CommandResult |
CommandResult ผลลัพธ์ของการดำเนินการ |
pushString
public CommandResult pushString (String contents, Path bucketPath)
อัปโหลดสตริงไปยังที่เก็บข้อมูล GCS
| พารามิเตอร์ | |
|---|---|
contents |
String: เนื้อหาไฟล์ในรูปแบบสตริง |
bucketPath |
Path: เส้นทางไฟล์ในที่เก็บข้อมูล GCS |
| คิกรีเทิร์น | |
|---|---|
CommandResult |
CommandResult ผลลัพธ์ของการดำเนินการ |
นำข้อมูลออก
public CommandResult remove (Path path)
นำไฟล์หรือไดเรกทอรีออกจากที่เก็บข้อมูล
| พารามิเตอร์ | |
|---|---|
path |
Path: เส้นทางที่จะนําออก |
| คิกรีเทิร์น | |
|---|---|
CommandResult |
|
นำข้อมูลออก
public CommandResult remove (Path path, boolean force)
นำไฟล์หรือไดเรกทอรีออกจากที่เก็บข้อมูล
| พารามิเตอร์ | |
|---|---|
path |
Path: เส้นทางที่จะนําออก |
force |
boolean: ระบุว่าจะดำเนินการไม่สำเร็จหรือไม่หากไม่มีไฟล์ |
| คิกรีเทิร์น | |
|---|---|
CommandResult |
|
removeBucket
public CommandResult removeBucket ()
นำที่เก็บข้อมูล GCS ออก
| คิกรีเทิร์น | |
|---|---|
CommandResult |
|
| การโยน | |
|---|---|
|
IOException |
setAttempts
public void setAttempts (int attempts)
| พารามิเตอร์ | |
|---|---|
attempts |
int |
setBotoConfig
public void setBotoConfig (String botoConfig)
| พารามิเตอร์ | |
|---|---|
botoConfig |
String |
setBotoPath
public void setBotoPath (String botoPath)
| พารามิเตอร์ | |
|---|---|
botoPath |
String |
setBucketName
public void setBucketName (String bucketName)
| พารามิเตอร์ | |
|---|---|
bucketName |
String |
setNoClobber
public void setNoClobber (boolean noClobber)
| พารามิเตอร์ | |
|---|---|
noClobber |
boolean |
setParallel
public void setParallel (boolean parallel)
| พารามิเตอร์ | |
|---|---|
parallel |
boolean |
setRecursive
public void setRecursive (boolean recursive)
| พารามิเตอร์ | |
|---|---|
recursive |
boolean |
setRetryInterval
public void setRetryInterval (long retryInterval)
| พารามิเตอร์ | |
|---|---|
retryInterval |
long |
setTimeout
public void setTimeout (long timeout,
TimeUnit unit)| พารามิเตอร์ | |
|---|---|
timeout |
long |
unit |
TimeUnit |
setTimeoutMs
public void setTimeoutMs (long timeout)
| พารามิเตอร์ | |
|---|---|
timeout |
long |
stat
public GCSBucketUtil.GCSFileMetadata stat (Path bucketPath)
รับสถานะของไฟล์สำหรับเส้นทาง GCS
| พารามิเตอร์ | |
|---|---|
bucketPath |
Path: เส้นทาง GCS |
| คิกรีเทิร์น | |
|---|---|
GCSBucketUtil.GCSFileMetadata |
GCSFileMetadata สำหรับเส้นทาง GCS |
| การโยน | |
|---|---|
|
IOException |