首页 > 解决方案 > 如何使用 C# 检查 Google Cloud Storage 中是否存在对象?

问题描述

有谁知道如何通过 C# 检查 Google Cloud Storage 存储桶中是否存在对象?

标签: c#.netgoogle-cloud-storage

解决方案


您可以使用 Google.Cloud.Storage.V1

using Google.Cloud.Storage.V1;

public class StorageClass 
{
    public bool IsObjectExist(string bucketName, string objectname)
    {
        var client = StorageClient.Create();
        return client.GetObject(bucketName, objectname) != null ? true : false;
    }
}

推荐阅读