cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco metadata

subhajit
Champ in-the-making
Champ in-the-making
Hi,

Using bulk upload I can create custom metadata. But can it be possible to create custom metadata when I "Add Conetent" or u can say uploading a single file. Suppose I want to upload one .jpg file and it will be added in alfresco with custom properties.

Thanks
1 REPLY 1

cheffilet
Champ in-the-making
Champ in-the-making
By now, you have to customize the flash-upload.get.html.ftl file to add your custom control-fields you want to set (like a categoy or custom meta-data textfield). Furthermore you have to edit the file flash-upload.js to add your values being set in your custom textfields into the uploadProcessor which means:

have a look at _uploadFromQueue where the attributes are being set for uploading - you can simply add your own attributes here like attributes["customer:myProp"] = "my str value".

On the server-side you have to process your attribtes by your own, you have to edit following file: upload.post.js. like following:


var filename = null;
var content = null;
var title = "";
var description = "";
var myProp = "";
for each (field in formdata.fields)
{
  //yourprop
  if(field.name == "customer:myProp") {
    myProp = field.value;
  }
  else if (field.name == "title")
  {
    title = field.value;
  }
  else if (field.name == "desc")
  {
    description = field.value;
  }
  else if (field.name == "file" && field.isFile)
  {
    filename = field.filename;
    content = field.content;
  }
}

// ensure mandatory file attributes have been located
if (filename == undefined || content == undefined)
{
  status.code = 400;
  status.message = "Uploaded file cannot be located in request";
  status.redirect = true;
}
else
{
  // create document in company home for uploaded file
  upload = companyhome.createFile("upload" + companyhome.children.length + "_" + filename) ;
  upload.properties.content.write(content);
  upload.properties.content.mimetype = "UTF-8";
  upload.properties.title = title;
  upload.properties.description = description;
  //your Prop here
  upload.properties["customer:myProp"] = myProp;
  upload.save();
 
  // setup model for response template
  model.upload = upload;
}