Google 會運用 AI 技術將內容翻譯成你偏好的語言,但可能會出錯。
使用 Unity 適用的 Cloud Storage 刪除檔案
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁面說明如何使用 Cloud Storage for Firebase SDK 刪除已上傳至 Cloud Storage bucket 的檔案。
注意: 根據預設,Cloud Storage for Firebase bucket 需要 Firebase Authentication 才能對 bucket 的資料或檔案執行任何動作。您可以變更 Cloud Storage 的 Firebase Security Rules ,允許在特定情況下進行未經驗證的存取 。不過,在大多數情況下,我們強烈建議限制存取權並設定完善的安全性規則 (尤其是正式版應用程式)。請注意,如果您使用 Google App Engine ,且預設 Cloud Storage bucket 的名稱格式為 *.appspot.com ,則可能需要考量安全性規則對 App Engine 檔案存取權的影響 。 刪除檔案
如要刪除檔案,請先建立該檔案的參照 。然後對該參照呼叫 DeleteAsync() 方法。
// Create a reference to the file to delete.
StorageReference desertRef = storageRef . Child ( "images/desert.jpg" );
// Delete the file
desertRef . DeleteAsync (). ContinueWithOnMainThread ( task = > {
if ( task . IsCompleted ) {
Debug . Log ( "File deleted successfully." );
}
else {
// Uh-oh, an error occurred!
}
});
注意: 刪除的檔案通常可在 7 天內復原,因為虛刪除 功能預設為啟用。
錯誤處理
刪除檔案時可能發生錯誤的原因有很多,包括檔案不存在,或使用者沒有刪除目標檔案的權限。如要進一步瞭解錯誤,請參閱「處理錯誤 」。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權 ,程式碼範例則為阿帕契 2.0 授權 。詳情請參閱《Google Developers 網站政策 》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2026-11-17 (世界標準時間)。
[null,null,["上次更新時間:2026-11-17 (世界標準時間)。"],[],[]]