frog0214 / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Update of Google Document removes all parent folders #632

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a Document Entry thru Google Data API ResumableUploader=> The 
document is added to the MyDrive (root) folder
2. move it to a subfolder thru MoveDocumentTo (e.g. Notes)  => The document is 
no visible in both folders, Drive root folder and Notes subfolder (why? When I 
move it, I would expect it only in the Notes folder afterwards, I didn't use 
CopeDocumentTo or soemthing else)
2. Update the same document with ResumableUploader => Now the document lost all 
its parentfolders (My Drive as well as Notes, why? It worked some months ago, 
but since the switch from Google Documents to Drive this seems not to work 
anymore, therefore I have now to move the document always again to Notes 
subfolder to have it listed there

What version of the product are you using? On what operating system?
GoogleDataApi 2.1.0 from 27-May-2012

Here is my code I am using:
private void SaveGoogleNote(Document GoogleNote)
{

        ResumableUploader uploader = new ResumableUploader();

        if (GoogleNote.DocumentEntry.Id.Uri != null)
        {

            uploader.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(OnGoogleNoteUpdated);    
            uploader.UpdateAsync(authenticator, GoogleNote.DocumentEntry, match);
            //uploader.Update(_authenticator, GoogleNote.DocumentEntry);

        }
        else
        {
            uploader.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(OnGoogleNoteCreated);
            // 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;
            googleNote.DocumentEntry.Links.Add(link);
            googleNote.DocumentEntry.Service = documentsRequest.Service;
            // Start the upload process   
            uploader.InsertAsync(authenticator, googleNote.DocumentEntry, UserData);
        }
}

private void OnGoogleNoteCreated(object sender, 
AsyncOperationCompletedEventArgs e)
{

    MoveGoogleNote(e.Entry as DocumentEntry, "create", e.Error, e.Cancelled);
}

private void OnGoogleNoteUpdated(object sender, 
AsyncOperationCompletedEventArgs e)
{
    MoveGoogleNote(e.Entry as DocumentEntry, "update", e.Error, e.Cancelled);
}

private void MoveGoogleNote(DocumentEntry entry, string title, Exception ex, 
bool cancelled)
{
    if (ex != null)
    {
        ErrorHandler.Handle(new Exception("Google Note couldn't be " + title + "d: " + entry == null ? null : entry.Title.Text, ex));
        return;
    }

    if (cancelled || entry == null)
    {
        ErrorHandler.Handle(new Exception("Google Note " + title + " was cancelled: " + entry == null ? null : entry.Title.Text));
        return;
    }

    //Move now to Notes subfolder    
    Document newNote = LoadGoogleNotes(entry.Id);
    newNote = DocumentsRequest.MoveDocumentTo(googleNotesFolder, newNote);

}

Original issue reported on code.google.com by Saller....@gmail.com on 14 Oct 2012 at 6:41

GoogleCodeExporter commented 8 years ago
is there any fix planned for this?

Original comment by Saller....@gmail.com on 16 Oct 2014 at 4:58