Edit metadata before file upload

Showing results for 
Search instead for 
Did you mean: 
Active Member

Edit metadata before file upload


I have done many searches on this subject but i can't make what i want after many attempts.

My objective is to customize the upload window to display the "edit metadata" form before the upload :

- Inside a folder which add an aspect on all uploaded files with a rule, the user selects one file on dnd-upload window.

- Instead of sending the file directly, i want to display the same form as in the "edit properties" popup (only for the aspect defined in the rule, the other folders without this aspect keep the same upload window)

- If the metadata are valid, upload the file with the metadata to create a 1.0 version.

Currently, I customized the edit form for the aspect through an extension file and everything works fine, i can see my fields when i edit uploaded file properties :

<config evaluator="aspect" condition="ns:myAspectName">
      <form id="doclib-simple-metadata">

But i can't find a way to display the form on the document upload page and then save the metadata with the file. Is it possible? Can someone explain me the steps to succeed that? Thanks.

2 Replies
Alfresco Employee

Re: Edit metadata before file upload

I'm not sure this addon is working with current Alfresco release:

GitHub - softwareloop/uploader-plus: An Alfresco uploader that prompts for metadata 

But it's providing the feature you are looking for.

Hyland Developer Evangelist
Active Member

Re: Edit metadata before file upload

Thank you. Yes, it's almost what i want. I can't use the addon directly, so i try to develop a similar one.

I have created a type in my model associated to the aspect :

   <type name="ns:typetest">

And I defined my form in the extension :

<config evaluator="model-type" condition="ns:typetest">


I can now display the form in a "metadata" div on the dnd-upload page with the following code :

Alfresco.DNDUpload.prototype.onFileSelection = function DNDUpload_onFileSelection(evt){
   Dom.removeClass("metadata", "hidden");
   var url = YAHOO.lang.substitute(
      + "?mode={mode}&itemKind={itemKind}&itemId={itemId}&htmlid={htmlid}"
      + "&destination={destination}&siteId={siteId}&containerId={containerId}&uploadDirectory={uploadDirectory}",
         serviceContext : Alfresco.constants.URL_SERVICECONTEXT,
         mode: "create",
         itemKind : "type",
         itemId : "alpro:typetest",
         htmlid : "something",
         destination: encodeURIComponent(this.showConfig.destination || ""), // empty field ?
         siteId: encodeURIComponent(this.showConfig.siteId || ""),
         containerId: encodeURIComponent(this.showConfig.containerId || ""),
         uploadDirectory: encodeURIComponent(this.showConfig.uploadDirectory || ""),
      url: url,
      successCallback: {
         fn: function(response) {
            YUIDom.get("metadata").innerHTML = response.serverResponse.responseText;
         scope: this

My next step is to send the form to save the file and the metadata but i don't know how to do it.

Currently, I can't send the form ("javax.servlet.ServletException: Possible CSRF attack noted when comparing token in session and request parameter. Request: POST /share/proxy/alfresco/api/type/ns%3Atypetest/formprocessor").

Can you explain me the step for the save ?