<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Failed to set the mime type for uploading file in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/failed-to-set-the-mime-type-for-uploading-file/m-p/11047#M4291</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Developers, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to import the msword file to alfresco repositry thru plain java code. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MY code is given below: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;public void createContentWithSpace(NodeRef nodeRef, String contentName, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ServiceRegistry serviceRegistry) { &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Map&amp;lt;QName, Serializable&amp;gt; contentProps = new HashMap&amp;lt;QName, Serializable&amp;gt;(); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;contentProps.put(ContentModel.PROP_NAME, contentName); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// create content node &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NodeService nodeService = serviceRegistry.getNodeService(); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ChildAssociationRef association = nodeService.createNode(nodeRef, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ContentModel.ASSOC_CONTAINS, QName.createQName( &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NamespaceService.CONTENT_MODEL_PREFIX, contentName), &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ContentModel.TYPE_CONTENT, contentProps); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NodeRef content = association.getChildRef(); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// add titled aspect (for Web Client display) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Map&amp;lt;QName, Serializable&amp;gt; titledProps = new HashMap&amp;lt;QName, Serializable&amp;gt;(); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;titledProps.put(ContentModel.PROP_TITLE, contentName); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;titledProps.put(ContentModel.PROP_DESCRIPTION, contentName); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;nodeService.addAspect(content, ContentModel.ASPECT_TITLED, titledProps); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//write content to the file &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;File file = new File("C:/Temp/Test.doc"); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ContentService contentService = serviceRegistry.getContentService(); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ContentWriter writer = contentService.getWriter(content, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ContentModel.PROP_CONTENT, true); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;String mimeType ="application/msword"; writer.setMimetype(mimeType); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;writer.putContent(file); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;} &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for msword document the mimetype is "application/msword" &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;writer.putContent(file); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in the above line i just the passed the file object. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code works perfectly. When i logged into webclient, i am able to see the imported document. The problem is when i clicking the imported msword document, a 'File Download' popup is enable and it provide options like 'open', 'save' and so on and it opened when i click the open &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;button. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My question : &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why I am getting the 'File Download' popup? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I upload the existing file through 'add content' link in Web Client, it uploading perfectly and also i can able to see the related icon for eg. for pdf file i can see the pdf icon and for msword document i can see the msword icon. When i click the document i didn't get any popup. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But when i upload through my java code, i am not able to see the related file icon like msword, pdf and so on. Do you know why it is? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there anything wrong in my code while setting the mimetype or do i need to set the encoding. If so how can i achive this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Jul 2006 11:10:34 GMT</pubDate>
    <dc:creator>srinivasan</dc:creator>
    <dc:date>2006-07-24T11:10:34Z</dc:date>
    <item>
      <title>Failed to set the mime type for uploading file</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/failed-to-set-the-mime-type-for-uploading-file/m-p/11047#M4291</link>
      <description>Hi Developers, I am trying to import the msword file to alfresco repositry thru plain java code. MY code is given below: public void createContentWithSpace(NodeRef nodeRef, String contentName, ServiceRegistry serviceRegistry) { Map&amp;lt;QName, Serializable&amp;gt; contentProps = new HashMap&amp;lt;QName, Seri</description>
      <pubDate>Mon, 24 Jul 2006 11:10:34 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/failed-to-set-the-mime-type-for-uploading-file/m-p/11047#M4291</guid>
      <dc:creator>srinivasan</dc:creator>
      <dc:date>2006-07-24T11:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to set the mime type for uploading file</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/failed-to-set-the-mime-type-for-uploading-file/m-p/11048#M4292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In the web client, check the Content Type property (viewable in the properties dialog) of the word document you created via your java class.&amp;nbsp; It should be "Microsoft Word".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Next, check the name of the document ends with ".doc" in your java code.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jul 2006 21:27:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/failed-to-set-the-mime-type-for-uploading-file/m-p/11048#M4292</guid>
      <dc:creator>davidc</dc:creator>
      <dc:date>2006-07-24T21:27:45Z</dc:date>
    </item>
  </channel>
</rss>

