【问题标题】:Google Cloud Storage .Net Client Bulk Upload谷歌云存储 .Net 客户端批量上传
【发布时间】:2021-11-10 21:05:53
【问题描述】:

我正在使用 .net 客户端将文件上传到云存储。 目前正在一个一个地上传文件

StorageClient client = StorageClient.Create();
foreach(file in files)
{
    client.UploadObject(bucketName, uploadLocation, contentType, file);
}

但我找不到批量上传文件的任何方法。有没有办法批量上传文件?

【问题讨论】:

  • 我只是在这里帮忙,没有时间给你详细的回复,但我发现了一些东西。您是否检查了有关执行可恢复上传的信息?请检查一下,现在我掌握了 JSON API,但我想你可以在你的代码中使用它。 cloud.google.com/storage/docs/…如果有帮助请告诉我。

标签: c# google-cloud-storage


【解决方案1】:

您实际上是在批量上传;你只是连续上传每个文件?

如果您正在寻找一种将files 提供给它并处理整个上传的方法,我不确定它是否存在。

您可以使用线程或等效方法并行运行上传。

您需要确保可以恢复失败的上传(上传多个文件会增加失败的可能性),请参阅Create Object Uploader

您需要自行管理故障恢复。

可能存在实现这种抽象的库。

【讨论】:

    【解决方案2】:

    我了解到您正在寻找一种在 Google Cloud Storage 中一次上传大量文件的方法。但是,没有直接的方法来处理整个上传。如果您有大量文件要上传,您可以执行并行多线程/多处理复制。应遵循以下步骤:

    1.Instantiation of a StorageClient object.
    2.Specifying the parallelization options.
    3.Getting a list of filenames from my upload folder and storing the names of the files.
    4.Getting a list of files in the cloud.
    5.Using the Parallel Foreach.
    6.calling the UploadObject method from the Google Cloud Storage client library.
    

    你也可以参考这个article了解更多关于上述方法的细节。

    【讨论】:

      猜你喜欢
      • 2016-03-21
      • 1970-01-01
      • 2017-11-23
      • 2019-05-08
      • 2017-11-11
      • 2016-01-17
      • 1970-01-01
      • 2014-09-25
      • 2014-05-04
      相关资源
      最近更新 更多