嵌套類 |
---|
class | GCSBucketUtil.GCSFileMetadata GCS 中文件資訊的簡單包裝。 |
公共構造函數
GCSBucketUtil
public GCSBucketUtil (String bucketName)
公共方法
複製
public CommandResult copy (String source,
String dest)
將檔案或目錄複製到儲存桶或從儲存桶複製檔案或目錄。
參數 |
---|
source | String : 原始檔或模式 |
dest | String : 目標檔案或模式 |
取得嘗試
public int getAttempts ()
取得BotoConfig
public String getBotoConfig ()
取得BotoPath
public String getBotoPath ()
取得桶名
public String getBucketName ()
取得NoClobber
public boolean getNoClobber ()
取得並行
public boolean getParallel ()
遞迴獲取
public boolean getRecursive ()
取得重試間隔
public long getRetryInterval ()
取得超時時間
public long getTimeout ()
是文件
public boolean isFile (String path)
檢查GCS檔案是否是檔案(資料夾)。
如果檔案名稱以“/”結尾,則它是一個資料夾。 gsutil ls gs://filename 如果是文件,則應傳回 gs://filename。如果資料夾中有文件,gsutil ls gs://資料夾名稱應該會傳回該資料夾中的文件。如果資料夾中沒有文件,它將傳回 gs://folder/。
參數 |
---|
path | String : 相對於儲存桶的路徑.. |
LS
public ls (Path bucketPath)
列出 GCS 路徑下的檔案。
md5哈希值
public String md5Hash (File localFile)
計算本地檔案的 md5 哈希值。
拉
public CommandResult pull (Path bucketPath,
File localFile)
從 GCS 儲存桶下載檔案或目錄。
參數 |
---|
bucketPath | Path :GCS儲存桶中的檔案路徑 |
localFile | File :本地目標路徑 |
拉
public CommandResult pull (Path bucketPath)
將檔案或目錄從GCS儲存桶下載到目前目錄。
參數 |
---|
bucketPath | Path :GCS儲存桶中的檔案路徑 |
拉取內容
public String pullContents (Path bucketPath)
從 GCS 儲存桶下載檔案並提取其內容。
參數 |
---|
bucketPath | Path :GCS儲存桶中的檔案路徑 |
推
public CommandResult push (File localFile)
將本機檔案或目錄上傳到GCS儲存桶。
參數 |
---|
localFile | File :本機檔案或目錄 |
推
public CommandResult push (File localFile,
Path bucketPath)
將本機檔案或目錄上傳到指定路徑的GCS儲存桶中。
參數 |
---|
localFile | File :本機檔案或目錄 |
bucketPath | Path :GCS儲存桶中的檔案路徑 |
推串
public CommandResult pushString (String contents,
Path bucketPath)
將字串上傳到 GCS 儲存桶。
參數 |
---|
contents | String :文件內容,作為字串 |
bucketPath | Path :GCS儲存桶中的檔案路徑 |
消除
public CommandResult remove (String pattern,
boolean force)
從儲存桶中刪除檔案或目錄。
參數 |
---|
pattern | String :要刪除的檔案、目錄或模式。 |
force | boolean : 是否忽略失敗並繼續靜默(不會拋出) |
消除
public CommandResult remove (Path path,
boolean force)
從儲存桶中刪除檔案或目錄。
參數 |
---|
path | Path : 要刪除的路徑 |
force | boolean : 如果檔案不存在是否失敗 |
消除
public CommandResult remove (String pattern)
從儲存桶中刪除檔案或目錄。
參數 |
---|
pattern | String :要刪除的檔案、目錄或模式。 |
設定嘗試次數
public void setAttempts (int attempts)
設定BotoConfig
public void setBotoConfig (String botoConfig)
設定BotoPath
public void setBotoPath (String botoPath)
設定Bucket名稱
public void setBucketName (String bucketName)
設定無破壞
public void setNoClobber (boolean noClobber)
設定並行
public void setParallel (boolean parallel)
設定遞迴
public void setRecursive (boolean recursive)
設定重試間隔
public void setRetryInterval (long retryInterval)
設定超時時間
public void setTimeout (long timeout,
TimeUnit unit)
參數 |
---|
timeout | long |
unit | TimeUnit |
設定超時時間
public void setTimeoutMs (long timeout)
受保護的方法
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2023-12-01 (世界標準時間)。
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"缺少我需要的資訊"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"過於複雜/步驟過多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"過時"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻譯問題"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/程式碼問題"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"容易理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"確實解決了我的問題"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]