簡體   English   中英

Google Cloud Storage API和Node.js

[英]Google Cloud Storage API and Node.js

我正在嘗試使用node.js客戶端庫來訪問googleAPI( https://github.com/google/google-api-nodejs-client )。 我正在嘗試使用Google Cloud Storage API插入存儲桶和對象。 我可以成功列出項目存儲區的存儲區。 也可以從存儲中檢索特定的存儲桶。 但無法插入存儲桶或對象。

進行API調用的代碼:

 googleapis.discover('storage', 'v1').execute(function(err,client){
    if(err)
     {
         console.log(err);
     }
  //insert bucket
  client.storage.buckets.insert({'project': "myproject_id",
                                 'resource': {'name': "mystorage-bucket"}})
                                  .withAuthClient(auth)
                                  .execute(function(err,result){
                                  console.log('error :',err,'inserted:',result);
                                 });

這是在日志中顯示的內容:

    error : { errors: 
                    [ { domain: 'global', 
                        reason: 'required', 
                        message: 'Required' } ],
              code: 400,
              message: 'Required' } inserted: null

有什么指示是“必填”,如何提供?

資源對象應作為.insert的第二個參數,如下所示:

client.storage.buckets.insert({ 
  'project': "myproject_id"
},
{
  'name': "mystorage-bucket"
}).withAuthClient(auth).execute(callback);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM