Sorry.  The definition of GDocumntsAllowedType is in the lib's source:
http://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/src/gdocuments/documentservice.cs#56

What is the exception/response from the server?

Eric

On Mon, Jun 15, 2009 at 3:37 PM, harry mendell <harry.mend...@gmail.com>wrote:

>
> Dear Eric,
> I tried adapting your code and wrote a test which I copied below.   It
> fails at
> DocumentEntry entry = service.Update(new 
> Uri(lastUploadEntry.MediaUri.ToString()),
> stream, "CSV", lastUploadEntry.Title.Text) as DocumentEntry;
> which is almost at the bottom. I think I'm having a some code of
> compatibility issue between the ACL and token auth, but this end of the pool
> is pretty deep.
> Would you mind taking a look?
> Thanks,
> Harry
>
>
>
>
>
>
> using System;
> using System.IO;
> using System.Collections;
> using System.Net;
> using System.Collections.Generic;
> using Google.Spreadsheets;
> using System.Linq;
> using System.Text;
> using Google.GData.Documents;
> using Google.GData.Client;
> using Google.GData.Extensions;
>
>
>
> namespace myfirstcsharp
> {
>
>     class Program
>     {
>         static void Main(string[] args)
>         {
>             DocumentsService service = new DocumentsService(
> "HBM-DocListUploader-1");
>             ((GDataRequestFactory)service.RequestFactory).KeepAlive =
> false;
>             service.setUserCredentials("qvtuat", "qvtqvtqvt");
>             //force the service to authenticate
>             DocumentsListQuery query = new DocumentsListQuery();
>             query.NumberToRetrieve = 1;
>             service.Query(query);
>
>
>             // For testing only. Creates document called radar.csv
>             DocumentEntry lastUploadEntry = service.UploadDocument(
> "c:/radar.csv", "radar.csv");
>             // For testing only. Now lets see if we can update it
>             FileInfo fileInfo = new FileInfo("c:/radar.csv");
>             FileStream stream = fileInfo.Open(FileMode.Open, FileAccess.Read,
> FileShare.ReadWrite);
>
>             try
>             {
>                 /* It didn't recogize GDocumntsAllowedType so I commented
> the check since I know its good type
>                 // convert the extension to caps and strip the "." off the
> front
>                 string ext = fileInfo.Extension.ToUpper().Substring(1);
>                 String contentType = (String)GDocumentsAllowedTypes[ext];
>
>                 if (contentType == null)
>                 {
>                     throw new ArgumentException("File extension '" + ext +
> "' is not recognized as valid.");
>                 }
>                 // Make sure we don't overwrite someone else's changes.
> Use entry's ETag
>              */
>                 GDataRequestFactory factory = (GDataRequestFactory
> )service.RequestFactory;
>                 factory.CustomHeaders.Add("If-Match: " +
> lastUploadEntry.Etag);
>                 service.RequestFactory = factory;
>                 DocumentEntry entry = service.Update(new 
> Uri(lastUploadEntry.MediaUri.ToString()),
> stream, "CSV", lastUploadEntry.Title.Text) as DocumentEntry;
>             }
>             finally
>             {
>                 stream.Close();
>             }
>         }
>     }
> }
>
>
> On Jun 11, 2009, at 5:16 PM, Eric (Google) wrote:
>
>
> This worked for me:
>
> DocumentsService service = new DocumentsService("yourCompany-AppName-
> v1");
> // TODO: Fetch DocumentEntry
> ReplaceDocContents(entryToUpdate, "C:\somewhere\test.doc");
> ...
>
> static public DocumentEntry ReplaceDocContents(DocumentEntry
> entryToUpdate, string replacementFileName)
> {
>  DocumentEntry entry = null;
>
>  FileInfo fileInfo = new FileInfo(replacementFileName);
>  FileStream stream = fileInfo.Open(FileMode.Open, FileAccess.Read,
> FileShare.ReadWrite);
>
>  try
>  {
>    // convert the extension to caps and strip the "." off the front
>    string ext = fileInfo.Extension.ToUpper().Substring(1);
>
>    String contentType = (String)GDocumentsAllowedTypes[ext];
>
>    if (contentType == null)
>    {
>        throw new ArgumentException("File extension '" + ext +
>                                    "' is not recognized as valid.");
>    }
>
>    // Make sure we don't overwrite someone else's changes.  Use
> entry's ETag
>    GDataRequestFactory factory = (GDataRequestFactory)
> service.RequestFactory;
>    factory.CustomHeaders.Add("If-Match: " + entryToUpdate.Etag);
>    service.RequestFactory = factory;
>
>    entry = service.Update(new Uri(entryToUpdate.MediaUri.ToString()),
>                           stream, contentType,
> entryToUpdate.Title.Text) as DocumentEntry;
>  }
>  finally
>  {
>    stream.Close();
>  }
>
>  return entry;
> }
>
> You may have more luck next time if the post isn't "write my app for
> me".
>
> Eric
>
> On Jun 11, 11:49 am, harry mendell <qvt...@gmail.com> wrote:
>
> I tried .net and first and can upload but not update. At this point I
>
> would be grateful for any solution. I've been at this for over a week
>
> and am ready to put my head through the wall:)
>
>
> PS I am able to do it a cell at a time with the spreadsheet api, but
>
> its slow, and besides I am not going to be able to sleep until I get
>
> this. I haven't felt like such a newbie since I poped out of my
>
> mother. Starting to feel postal.
>
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Docs Data APIs" group.
To post to this group, send email to Google-Docs-Data-APIs@googlegroups.com
To unsubscribe from this group, send email to 
google-docs-data-apis+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Docs-Data-APIs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to