无法上传到特定的文件夹得到503错误

问题描述:

我想上传一个简单的文本文件到谷歌文件中的特定文件夹,但没有运气。无法上传到特定的文件夹得到503错误

FileStream fileStream = new FileStream(@"c:\test.txt", System.IO.FileMode.Open); 
DocumentEntry lastUploadEntry = 
    globalData.service.UploadDocument("c:\\test.txt", null);                    

string feed = 
    "https://docs.google.com/feeds/upload/create-session/default/private/full/folder%folder:0B2dzFB6YvN-kYTRlNmNhYjEtMTVmNC00ZThkLThiMjQtMzFhZmMzOGE2ZWU1/contents/"; 

var result = 
    globalData.service.Insert(new Uri(feed), fileStream, "application/pdf", "test"); 

我得到一个错误说

"The remote server returned an error: (503) Server Unavailable."

我怀疑该目标文件夹URI是错误的,但我不能找出正确的。

有在https://developers.google.com/google-apps/documents-list/#uploading_a_new_document_or_file_with_both_metadata_and_content使用可恢复上传组件的完整示例:

using System; 
using Google.GData.Client; 
using Google.GData.Client.ResumableUpload; 
using Google.GData.Documents; 

namespace MyDocumentsListIntegration 
{ 
    class Program 
    { 
    static void Main(string[] args) 
    { 
     DocumentsService service = new DocumentsService("MyDocumentsListIntegration-v1"); 

     // TODO: Instantiate an Authenticator object according to your authentication 
     // mechanism (e.g. OAuth2Authenticator). 
     // Authenticator authenticator = ... 

     // Instantiate a DocumentEntry object to be inserted. 
     DocumentEntry entry = new DocumentEntry(); 

     // Set the document title 
     entry.Title.Text = "Legal Contract"; 

     // Set the media source 
     entry.MediaSource = new MediaFileSource("c:\\contract.txt", "text/plain"); 

     // Define the resumable upload link 
     Uri createUploadUrl = new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full"); 
     AtomLink link = new AtomLink(createUploadUrl.AbsoluteUri); 
     link.Rel = ResumableUploader.CreateMediaRelation; 
     entry.Links.Add(link); 

     // Set the service to be used to parse the returned entry 
     entry.Service = service; 

     // Instantiate the ResumableUploader component. 
     ResumableUploader uploader = new ResumableUploader(); 

     // Set the handlers for the completion and progress events 
     uploader.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(OnDone); 
     uploader.AsyncOperationProgress += new AsyncOperationProgressEventHandler(OnProgress); 

     // Start the upload process 
     uploader.InsertAsync(authenticator, entry, new object()); 
    } 

    static void OnDone(object sender, AsyncOperationCompletedEventArgs e) { 
     DocumentEntry entry = e.Entry as DocumentEntry; 
    } 

    static void OnProgress(object sender, AsyncOperationProgressEventArgs e) { 
     int percentage = e.ProgressPercentage; 
    } 
    } 
} 

只要按照文章Google Apps Platform Uploading documents
还检查了Google Documents List API version 3.0
开放的应该是类似下面:

string feed = @"https://developers.google.com/google-apps/documents-list/#getting_a_resource_entry_again"; 
//it may not be exact, just check and read from the links 
+0

你可以告诉我,如果饲料尿素是正确的吗?我怀疑这是问题。 – 2012-04-18 19:28:49

+0

我不知道,错误503是服务不可用,http://www.checkupdown.com/status/E503.html – Habib 2012-04-18 19:30:56

+0

好吧,我真的很感谢你的帮助。请注意。 – 2012-04-18 19:34:57

试试这个uri:

"https://docs.google.com/feeds/default/private/full/folder%3A" + fRid + "/contents" 

// FRID是该文件夹的资源ID ..你的情况:0B2dzFB6YvN-kYTRlNmNhYjEtMTVmNC00ZThkLThiMjQtMzFhZmMzOGE2ZWU1

而且我猜你的URI是因为你正在使用的文件夹资源ID作为给这个错误 - 文件夹:RESOURCEID

尝试删除文件夹:,只使用RID

代码,以切断 “文件夹:” -

int ridIndex = dRid.IndexOf(":"); 
Rid = Rid.Substring(ridIndex + 1);