<?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 Create a file inside repository via Java backed Web Script. in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/create-a-file-inside-repository-via-java-backed-web-script/m-p/265727#M218857</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm using Alfresco 4.0 version.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to write a webscript which creates a new file inside alfresco repository (inside folder "/Company Home/myfolder"), but I can't find a way to do it &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://connect.hyland.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By following &lt;/SPAN&gt;&lt;A href="http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples" rel="nofollow noopener noreferrer"&gt;http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples&lt;/A&gt;&lt;SPAN&gt; examples, I managed to write a webscript which returns a content of a file to user, but how can a java backed webscript generate and store a new (binary) file inside Alfresco repository.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I read a lot of examples and forum posts, but none seem to work for this Alfresco version, or at least I didn't realize how to do it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;NodeRef companyHome = repository.getCompanyHome();&lt;BR /&gt;List&amp;lt;String&amp;gt; nodes = new ArrayList&amp;lt;String&amp;gt;();&lt;BR /&gt;nodes.add("myfolder");&lt;BR /&gt;&lt;BR /&gt;NodeRef where = registry.getFileFolderService().resolveNamePath(companyHome, nodes).getNodeRef();&lt;BR /&gt;registry.getFileFolderService().create(where, "myfile",QNAME);&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;but I don't know what to put for QName parameter. It can't be null.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Nov 2011 23:38:11 GMT</pubDate>
    <dc:creator>cile87</dc:creator>
    <dc:date>2011-11-29T23:38:11Z</dc:date>
    <item>
      <title>Create a file inside repository via Java backed Web Script.</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/create-a-file-inside-repository-via-java-backed-web-script/m-p/265727#M218857</link>
      <description>I'm using Alfresco 4.0 version.I'm trying to write a webscript which creates a new file inside alfresco repository (inside folder "/Company Home/myfolder"), but I can't find a way to do it &lt;IMG id="smileysad" class="emoticon emoticon-smileysad" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;By following http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples examples, I managed to write a web</description>
      <pubDate>Tue, 29 Nov 2011 23:38:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/create-a-file-inside-repository-via-java-backed-web-script/m-p/265727#M218857</guid>
      <dc:creator>cile87</dc:creator>
      <dc:date>2011-11-29T23:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create a file inside repository via Java backed Web Script.</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/create-a-file-inside-repository-via-java-backed-web-script/m-p/265728#M218858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I managed to create an empty file:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;import …&lt;BR /&gt;import org.alfresco.model.ContentModel;&lt;BR /&gt;import org.alfresco.repo.model.Repository;&lt;BR /&gt;import org.alfresco.service.ServiceRegistry;&lt;BR /&gt;import org.alfresco.service.cmr.repository.NodeRef;&lt;BR /&gt;…&lt;BR /&gt;private ServiceRegistry registry;&lt;BR /&gt;…&lt;BR /&gt;NodeRef companyHome = repository.getCompanyHome();&lt;BR /&gt;List&amp;lt;String&amp;gt; nodes = new ArrayList&amp;lt;String&amp;gt;();&lt;BR /&gt;nodes.add("myfolder");&lt;BR /&gt;&lt;BR /&gt;NodeRef where = registry.getFileFolderService().resolveNamePath(companyHome, nodes).getNodeRef();&lt;BR /&gt;registry.getFileFolderService().create(where, "myfile", ContentModel.TYPE_CONTENT);&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;but now I'm trying to write an byte stream into that file. In fact, what I'm trying to do, is store serilized java object inside Alfresco repository.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 01:46:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/create-a-file-inside-repository-via-java-backed-web-script/m-p/265728#M218858</guid>
      <dc:creator>cile87</dc:creator>
      <dc:date>2011-11-30T01:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create a file inside repository via Java backed Web Script.</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/create-a-file-inside-repository-via-java-backed-web-script/m-p/265729#M218859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;YEY! I discovered how to put a content:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;ContentWriter writer = registry.getFileFolderService().getWriter(createdFile);&lt;BR /&gt;writer.putContent("lorem ipsum dolorem");&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;putContent method also receives an InputStream so it shouldn't be a problem to work with java serialization.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;–&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you discover it, it looks so darm simple.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 02:10:57 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/create-a-file-inside-repository-via-java-backed-web-script/m-p/265729#M218859</guid>
      <dc:creator>cile87</dc:creator>
      <dc:date>2011-11-30T02:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create a file inside repository via Java backed Web Script.</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/create-a-file-inside-repository-via-java-backed-web-script/m-p/265730#M218860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;An alternative way to create a new node in the repository is to use the Alfresco Foundation API using the NodeService and the ContentService.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From the registry you could get the NodeService and create the node for the content with all the properties. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then you can use the ContentService to write the byte stream for the node.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Alfresco Foundation API:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://wiki.alfresco.com/wiki/Java_Foundation_API" rel="nofollow noopener noreferrer"&gt;http://wiki.alfresco.com/wiki/Java_Foundation_API&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway if you download the Alfresco SDK you will find many examples about how to use the Alfresco Foundation API, it could be very useful to understand all the features and operations that you can execute against the repository.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 09:01:24 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/create-a-file-inside-repository-via-java-backed-web-script/m-p/265730#M218860</guid>
      <dc:creator>openpj</dc:creator>
      <dc:date>2011-11-30T09:01:24Z</dc:date>
    </item>
  </channel>
</rss>

