Google Sites API - File Cabinets: Spaces and extension separator (.) are removed from file names

Posted by user1299447 on Stack Overflow See other posts from Stack Overflow or by user1299447
Published on 2012-03-28T23:26:17Z Indexed on 2012/03/28 23:29 UTC
Read the original article Hit count: 157

Filed under:
|

We have a series of internal reports that we update regularly from our internal databases. We built an application in C# that uploads these reports to a Google Site. Everything works fine, except that the name of the file shown to the final user in the File Cabinet does not include the original spaces nor the extension separator (.)

For example, Stock per warehouse.pdf is shown as : Stockperwarehousepdf

Below is a simplified version of the code.

private AtomEntry UploadAttachment(string filename, AtomEntry parent, string title, string description)
        {
        SiteEntry entry = new SiteEntry();           

        AtomCategory category = new AtomCategory(SitesService.ATTACHMENT_TERM, SitesService.KIND_SCHEME);

        category.Label = "attachment";
        entry.Categories.Add(category);

        AtomLink parentLink = new AtomLink(AtomLink.ATOM_TYPE, SitesService.PARENT_REL);

        parentLink.HRef = parent.SelfUri;

        entry.Links.Add(parentLink);                        
        entry.MediaSource = new MediaFileSource(filename, MediaFileSource.GetContentTypeForFileName(filename));
        entry.Content.Type = MediaFileSource.GetContentTypeForFileName(filename);


        entry.Title.Text= title;                
        entry.Summary.Text = description;                        

        AtomEntry newEntry = null;            

        newEntry = service.Insert(new Uri(makeFeedUri("content")), entry);  
}

The key line is where the MediaFileSource object is created. Any idea of what we are missing? I've tried all sort of changes :(

© Stack Overflow or respective owner

Related posts about c#

Related posts about google-sites