场景:与dcm API相关的存储桶中存储了多个文件夹和许多文件.(单击,展示,每日汇总文件等). console.cloud.google/storage/browser/dcmaccountno
Scenario: there are multiple folders and many files stored in storage bucket related to dcm API.(click,impression,daily aggregate files etc). console.cloud.google/storage/browser/dcmaccountno
是否可以使用rest api下载文件,当前我具有服务帐户和私钥. 我们对goog云存储没有太多了解,因此任何小小的帮助都是非常可观的.
Is it possible to download files using rest api and currently i have service account and private key. we dont have much exposure towards goog cloud storage hence any small help would be really appreciable.
谢谢您的帮助!
推荐答案使用rest API,您可以按照以下链接中已经介绍的以下方式从Google存储空间下载/上传文件:
Using rest API you can download/upload files from google storage in the following way that I already did in the below-mentioned link:
参考: stackoverflow/a/53955058/4345389
您可以通过以下方式使用DownloadData方法来代替WebClient的UploadData方法:
Instead of UploadData method of WebClient, you can use DownloadData method in the following way:
// Create a new WebClient instance. using (WebClient client= new WebClient()) { client.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + bearerToken); client.Headers.Add(HttpRequestHeader.ContentType, "application/octet-stream"); // Download the Web resource and save it into a data buffer. byte[] bytes = client.DownloadData(body.SourceUrl); MemoryStream memoryStream = new MemoryStream(bytes); // TODO write further funcitonality to write the memorystream }根据您的要求进行一些调整.
Do some tweaks as per your requirements.
更多推荐
如何使用Rest API在Google Cloud Storage中下载文件
发布评论