cancel
Showing results for 
Search instead for 
Did you mean: 

Adding custom type while uploading document using web script

arpit_gupta
Champ in-the-making
Champ in-the-making
Hello Friends,

I am using Alfresco 4.0.b community edition with default solr implementation.

I am uploading documents in alfresco using upload web script as mentioned at http://wiki.alfresco.com/wiki/Web_Scripts_Examples#Upload_Script

I have created a web script for searching documents using CMIS query.
I have added some meta tags while uploading the documents and want to search documents using those metatags.
For this purpose i have created a custom document type prop:documents and added my custom meta tags like propSmiley Tongueropertyid, prop:agreementid to it.

Now while uploading the document i have to add prop:documents as object type.
So can someone please suggest me how to add custom object type while uploading document using upload web script.

Thanks,
Arpit
2 REPLIES 2

openpj
Elite Collaborator
Elite Collaborator
During the upload process in the POST WebScript, you can specialize your new node using the specializeType method available in the ScriptNode, in this way:

// create document in company home for uploaded file
  upload = companyhome.createFile("upload" + companyhome.children.length + "_" + filename) ; 

  upload.properties.content.write(content);
  upload.properties.content.setEncoding("UTF-8");
  upload.properties.content.guessMimetype(filename);



  upload.specializeType("prop:documents");
  upload.properties["yourCustomPrefix:yourCustomProperty1"] = value1;
  upload.properties["yourCustomPrefix:yourCustomProperty2"] = value2;
  …
  … 
  upload.properties.title = title;
  upload.properties.description = description;
  upload.save();

  // setup model for response template
  model.upload = upload;
Hope this helps.

arpit_gupta
Champ in-the-making
Champ in-the-making
Thanks Dear!!! It helped.. Smiley Happy