cancel
Showing results for 
Search instead for 
Did you mean: 

how to get siteId and containerId

lakshya
Champ in-the-making
Champ in-the-making
What is siteId and containerId?
How can we get this to set while uploading any document through REStful APIs.

Regards
12 REPLIES 12

kaynezhang
World-Class Innovator
World-Class Innovator
I have not tested in alfresco 4.x ,but it works fine in alfresco 5.
Following code is extracted from upload.post.js in alfresco 5.0

            case "uploaddirectory":
               uploadDirectory = fnFieldValue(field);
               if ((uploadDirectory !== null) && (uploadDirectory.length() > 0))
               {
                  if (uploadDirectory.charAt(uploadDirectory.length() - 1) != "/")
                  {
                     uploadDirectory = uploadDirectory + "/";
                  }
                  // Remove any leading "/" from the uploadDirectory
                  if (uploadDirectory.charAt(0) == "/")
                  {
                     uploadDirectory = uploadDirectory.substr(1);
                  }
               }
               break;

koopa
Confirmed Champ
Confirmed Champ
I also tried this "test" code on js.do and all seems ok with every combination of "string + /" … Don't know what to think.
<javascript>
<label>string</label><input id="s" type="text" value="string"></input>
<p id="u1" style="border: 1px solid;" />
<p id="u2" style="border: 1px solid;" />
<p id="u3" style="border: 1px solid;" />
<p id="u4" style="border: 1px solid;" />
<p id="u5" style="border: 1px solid;" />

<div>
   <input type="button" value="click" onClick="show()" />
</div>
<script>
function show() {
   var uploadDirectory = $("#s").val();
    $("#u1").html("uploadDirectory="+uploadDirectory);
    $("#u2").html("uploadDirectory.substr(1)="+uploadDirectory.substr(1));
    $("#u3").html("uploadDirectory.substr(0, 1)="+uploadDirectory.substr(0,1));
    $("#u4").html("uploadDirectory.substring(uploadDirectory.length - 1)="+uploadDirectory.substring(uploadDirectory.length - 1));
  
   if (uploadDirectory !== null) {   
       // Remove any leading "/" from the uploadDirectory
       if (uploadDirectory.substr(0, 1) == "/") {
           uploadDirectory = uploadDirectory.substr(1);
       }
       // Ensure uploadDirectory ends with "/" if not the root folder
       if ((uploadDirectory.length > 0) &&(uploadDirectory.substring(uploadDirectory.length - 1) != "/")) {
           uploadDirectory = uploadDirectory + "/";
       }
   }
    $("#u5").html("uploadDirectory="+uploadDirectory);
}
</javascript>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>

kaynezhang
World-Class Innovator
World-Class Innovator
I tested the code in java ,I guess maybe yours has something to do with javascript slash character  escaping.