מנהל קבצים כדי להוריד ולהעלות קבצים מ-Google Cloud Storage (GCS).
אין להשתמש במחלקה זו מתוך היקף מבחן (כלומר, IRemoteTest). זה הוצא משימוש, אנא השתמש במקום זאת GCSFileDownloader
.
כיתות מקוננות |
---|
class | GCSBucketUtil.GCSFileMetadata מעטפת פשוטה למידע על קובץ ב-GCS. |
בנאים ציבוריים
GCSBucketUtil
public GCSBucketUtil (String bucketName)
פרמטרים |
---|
bucketName | String |
שיטות ציבוריות
עותק
public CommandResult copy (String source,
String dest)
העתק קובץ או ספרייה אל הדלי או ממנו.
פרמטרים |
---|
source | String : קובץ מקור או דפוס |
dest | String : קובץ יעד או דפוס |
getAttempts
public int getAttempts ()
getBotoConfig
public String getBotoConfig ()
getBotoPath
public String getBotoPath ()
getBucketName
public String getBucketName ()
getNoClobber
public boolean getNoClobber ()
getParallel
public boolean getParallel ()
getRecursive
public boolean getRecursive ()
getRetryInterval
public long getRetryInterval ()
getTimeout
public long getTimeout ()
isFile
public boolean isFile (String path)
בדוק שקובץ GCS הוא קובץ או לא קובץ (תיקיה).
אם שם הקובץ מסתיים ב-'/', אז זו תיקיה. gsutil ls gs://filename צריך להחזיר את gs://filename אם זה קובץ. gsutil ls gs://folder name אמור להחזיר את הקבצים בתיקייה אם יש קבצים בתיקייה. וזה יחזיר gs://folder/ אם אין קבצים בתיקייה.
פרמטרים |
---|
path | String : הנתיב ביחס לדלי.. |
החזרות |
---|
boolean | זה קובץ או לא קובץ. |
ls
public ls (Path bucketPath)
רשום קבצים תחת נתיב GCS.
פרמטרים |
---|
bucketPath | Path : נתיב GCS |
makeBucket
public CommandResult makeBucket (String projectId)
הכינו את דלי GCS.
md5Hash
public String md5Hash (File localFile)
חשב את ה-hash של md5 עבור הקובץ המקומי.
פרמטרים |
---|
localFile | File : קובץ מקומי |
החזרות |
---|
String | ה-hash md5 עבור הקובץ המקומי. |
מְשׁוֹך
public CommandResult pull (Path bucketPath,
File localFile)
הורד קובץ או ספרייה מדלי GCS.
פרמטרים |
---|
bucketPath | Path : נתיב קובץ בדלי GCS |
localFile | File : נתיב יעד מקומי |
מְשׁוֹך
public CommandResult pull (Path bucketPath)
הורד קובץ או ספרייה מדלי GCS לספרייה הנוכחית.
פרמטרים |
---|
bucketPath | Path : נתיב קובץ בדלי GCS |
pullContents
public String pullContents (Path bucketPath)
הורד קובץ מדלי GCS וחלץ את תוכנו.
פרמטרים |
---|
bucketPath | Path : נתיב קובץ בדלי GCS |
החזרות |
---|
String | תוכן מחרוזת של הקובץ |
לִדחוֹף
public CommandResult push (File localFile)
העלה קובץ או ספריה מקומיים לדלי GCS.
פרמטרים |
---|
localFile | File : קובץ מקומי או ספריה |
לִדחוֹף
public CommandResult push (File localFile,
Path bucketPath)
העלה קובץ או ספריה מקומיים לדלי GCS עם נתיב ספציפי.
פרמטרים |
---|
localFile | File : קובץ מקומי או ספריה |
bucketPath | Path : נתיב קובץ בדלי GCS |
pushString
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 (Path path)
הסר קובץ או ספרייה מהדלי.
פרמטרים |
---|
path | Path : נתיב להסרה |
לְהַסִיר
public CommandResult remove (String pattern)
הסר קובץ או ספרייה מהדלי.
פרמטרים |
---|
pattern | String : קובץ, ספרייה או דפוס להסרה. |
קבע ניסיונות
public void setAttempts (int attempts)
setBotoConfig
public void setBotoConfig (String botoConfig)
פרמטרים |
---|
botoConfig | String |
setBotoPath
public void setBotoPath (String botoPath)
setBucketName
public void setBucketName (String bucketName)
פרמטרים |
---|
bucketName | String |
setNoClobber
public void setNoClobber (boolean noClobber)
פרמטרים |
---|
noClobber | boolean |
setParallel
public void setParallel (boolean parallel)
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)
שיטות מוגנות
getRunUtil
protected IRunUtil getRunUtil ()
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2023-03-30 (שעון UTC).
[{
"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":"סיבה אחרת"
}]