ตั้งแต่ปี 2026 เป็นต้นไป เราจะเผยแพร่ซอร์สโค้ดไปยัง AOSP ในไตรมาสที่ 2 และ 4 เพื่อให้สอดคล้องกับโมเดลการพัฒนาที่เสถียรของ Trunk และรับประกันความเสถียรของแพลตฟอร์มสำหรับระบบนิเวศ เราขอแนะนำให้ใช้ android-latest-release แทน aosp-main ในการสร้างและมีส่วนร่วมใน AOSP android-latest-release สาขาไฟล์ Manifest จะอ้างอิงถึงรุ่นล่าสุดที่พุชไปยัง AOSP เสมอ ดูข้อมูลเพิ่มเติมได้ที่การเปลี่ยนแปลงใน AOSP
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
GCSFileDownloaderBase
public
class
GCSFileDownloaderBase
extends GCSCommon
คลาสย่อยโดยตรงที่ทราบ
| GCSFileDownloader |
โปรแกรมดาวน์โหลดไฟล์เพื่อดาวน์โหลดไฟล์จาก Google Cloud Storage (GCS)
|
|
โปรแกรมดาวน์โหลดไฟล์เพื่อดาวน์โหลดไฟล์จาก Google Cloud Storage (GCS)
สรุป
เมธอดสาธารณะ |
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)
|
ค่าคงที่
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 |
downloadFile
public InputStream downloadFile (String bucketName,
String filename)
ดาวน์โหลดไฟล์จากไฟล์ที่เก็บข้อมูล GCS
| พารามิเตอร์ |
bucketName |
String: ชื่อที่เก็บข้อมูล GCS |
filename |
String: ชื่อไฟล์ |
downloadFile
public void downloadFile (String remotePath,
File destFile)
| พารามิเตอร์ |
remotePath |
String |
destFile |
File |
downloadFile
public File downloadFile (String remoteFilePath)
| พารามิเตอร์ |
remoteFilePath |
String |
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 ฟังก์ชันนี้ใช้ได้กับทั้ง 2 กรณี แต่
เราไม่ควรพยายามดาวน์โหลดโฟลเดอร์ที่มีขนาดเป็น 0
| พารามิเตอร์ |
bucketName |
String: คือชื่อที่เก็บข้อมูล GCS |
filename |
String: คือเส้นทางที่เกี่ยวข้องไปยังที่เก็บข้อมูล |
| คิกรีเทิร์น |
boolean |
เป็นจริงหากชื่อไฟล์เป็นโฟลเดอร์ มิเช่นนั้นจะเป็นเท็จ |
sanitizeDirectoryName
public String sanitizeDirectoryName (String name)
วิธีการที่ได้รับการป้องกัน
createTempFile
protected File createTempFile (String remoteFilePath,
File rootDir)
| พารามิเตอร์ |
remoteFilePath |
String |
rootDir |
File |
downloadFile
protected void downloadFile (String bucketName,
String remoteFilename,
File localFile)
| พารามิเตอร์ |
bucketName |
String |
remoteFilename |
String |
localFile |
File |
getStorage
protected Storage getStorage ()
listRemoteFilesUnderFolder
protected void listRemoteFilesUnderFolder (String bucketName,
String folder,
subFiles,
subFolders)
| พารามิเตอร์ |
bucketName |
String |
folder |
String |
subFiles |
|
subFolders |
|
parseGcsPath
protected String[] parseGcsPath (String remotePath)
| พารามิเตอร์ |
remotePath |
String |
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-12-04 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-12-04 UTC"],[],[]]