Xóa file bằng Cloud Storage cho C++

Sau khi tải file lên Cloud Storage, bạn cũng có thể xóa chúng.

Xóa một tập tin

Để xóa một tập tin, trước tiên hãy tạo một tham chiếu đến tập tin đó. Sau đó gọi phương thức Delete() trên tham chiếu đó.

// Create a reference to the file to delete.
StorageReference *desert_ref = storage_ref.Child("images/desert.jpg");

// Delete the file
Future future = desert_ref.Delete();

// Wait for operation to complete...

if (future.Error() != firebase::storage::kErrorNone) {
  // Uh-oh, an error occurred!
} else {
  // File deleted successfully
}

Xử lý lỗi

Có một số lý do có thể xảy ra lỗi khi xóa tệp, bao gồm cả tệp không tồn tại hoặc người dùng không có quyền xóa tệp mong muốn. Bạn có thể tìm thêm thông tin về lỗi trong phần Xử lý lỗi của tài liệu.