2015-06-29 53 views
0

我試圖使用.NET API在Google雲端存儲中的存儲桶之間複製和移動對象。至於我可以告訴我正確構建的要求,我已經驗證了我的全部低於設置的屬性是正確的,他們應該是什麼,但我得到以下神祕的錯誤:谷歌雲存儲中的CopyRequest和RewriteRequest錯誤

Google.GoogleApiException : Google.Apis.Requests.RequestError 
Required [400] 
Errors [ 
    Message[Required] Location[ - ] Reason[required] Domain[global] 
] 

這裏是代碼

Google.Apis.Storage.v1.Data.Object moveObj = new Google.Apis.Storage.v1.Data.Object() { Name = key, Size = (ulong)Length, ContentType = contentType }; 
ObjectsResource.RewriteRequest req = new ObjectsResource.RewriteRequest(_gcsClient, newObj,sourceBucket, key, destBucket, key); 
req.Execute(); 

任何想法我可能做錯了什麼?

回答

1

我想通了我自己,希望這個答案會幫助你,如果你有同樣的問題。相信這個寫得不好和不一致的雲存儲API比什麼都重要。當你創建一個存儲「對象」你指定的名稱(見第一個參數)每隔操作:

new Google.Apis.Storage.v1.Data.Object() { Name = key, Size = (ulong)Length, ContentType = contentType }; 

但出於某種原因,這個試圖移動或在這種情況下,您可以複製的對象,所以當斷省略它,因爲無論如何您都將destinationKey作爲屬性傳遞給WriteRequest/CopyRequest,所以如下所示:

new Google.Apis.Storage.v1.Data.Object() {Size = (ulong)Length, ContentType = contentType };