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

mikeh
Star Contributor
Star Contributor
Those are specifically for uploading into Share sites. SiteId should be self-explanatory, ContainerId is the space to upload to, e.g. "documentLibrary" for the Document Library default space.

There are other REST APIs to get a list of sites for example: http://wiki.alfresco.com/wiki/3.0_REST_API

Thanks,
Mike

lakshya
Champ in-the-making
Champ in-the-making
Thanks Mike,
But what if I want to upload in a folder  created by me like "Test Folder" if i give like "testfolder" it doesnt accept.
How can i set / get the name of folders.

mikeh
Star Contributor
Star Contributor
The you shouldn't be using the Share APIs  :wink:

Have a look here instead:
- your own upload webscript: http://wiki.alfresco.com/wiki/Web_Scripts_Examples#File_Upload
- the upload content servlet: http://wiki.alfresco.com/wiki/URL_Addressability#UploadContentServlet

Thanks,
Mike

martinn
Champ in-the-making
Champ in-the-making
Those are specifically for uploading into Share sites. SiteId should be self-explanatory…

The first sentence seems not to be correct. Because these parameter are also necessary if someone will upload files calling the webscript /api/upload.

SiteId? May be that is clear for you. But what about people who are new to Alfresco?

Until now I found only one page - http://wiki.alfresco.com/wiki/3.0_REST_API - where are some word about this Id.
siteId (equivalent to site shortname) has a well-defined max length - note: activities service schema currently accommodates siteIds upto 255 characters
Ok. I have a standard Alfresco installation. If I look into the repository there is a folder "Sites" and because I did not define a site this folder is empty.
Also I have created a folder "TestArchive". I want to upload files to this folder calling the webscript /api/upload. And here a SiteId is required. Can anybody tell me what I have to use?

mikeh
Star Contributor
Star Contributor
The easiest way is to get the node reference of the TestArchive folder (you can get that from the details page) then use that as a "destination" parameter in the POST request, instead of siteId and containerId.

For some reason that upload webscript isn't particularly well documented, but you essentially either upload using Share siteId, containerId and path, or by node reference ("destination") anywhere in the Repository (can include Sites).

Thanks,
Mike

oops_007
Champ in-the-making
Champ in-the-making
I have done a complete Install of Alfresco 3.4 CE. Jst used the allready existing mysql Db but installed all the services(Tomcat/alfresco.. OpenOffice…etc) that come along with the Install.

I am able to Upload the documents from the Alfresco.war file that is deployed in the Tomcat..

Now I am trying to use Java API to to do Upload Document..
But I am not getting what to set for SiteId and Container Id…. ??
Has any one got this working..?

Does any one have RestAPI complete example to upload a Document to Alfresco….

oops_007
Champ in-the-making
Champ in-the-making
I was able to figure out that SiteId is something that has to be created on Alfresco Share : http://loclahost:8080/share - use same credentials that you use for alfresco site..

But the Upload Directory is not working. I am giving the Upload Directory is not working.. I am getting error as " directory does not exists..

       new StringPart("siteid", "PersonalFolder"),
   new StringPart("containerid", "documentLibrary"),
   new StringPart("uploaddirectory", "/home/username/alfresco-3.4.d/alf_data/")
………..

Has any one got the File Upload Java API code working?

mikeh
Star Contributor
Star Contributor
Upload directory is relative to the Site, not a physical filesystem. So if you have a folder called "docs" in the site, the upload directory would be "docs"

Look at the existing upload code for Share to see examples - e.g. html-upload.js

Thanks,
Mike

koopa
Confirmed Champ
Confirmed Champ
the "uploaddirectory" parameter seems to be ignored, are you sure it works? I have a folder called "raps" in my site under "documentLibrary" but when in my uload script I use "siteid", "containerid" ("documentLibrary") and "uploaddirectory" the last one is ignored.

EDIT:
As I said <a href="https://forums.alfresco.com/comment/149824#comment-149824">here</a> I really don't know why but I found that to upload to a specific directory I have to give the uploaddirectory parameter with '/' at first and last char of the string. I mean:
<ol>
<li>"dir" won't work</li>
<li>"/dir" won't work</li>
<li>"dir/" won't work</li>
<li>"/dir/" works!</li>
</ol>

and it is really strange because the code in upload.post.js (here from line 85) seems fine…
<javascript>
case "uploaddirectory":
   uploadDirectory = fnFieldValue(field);
   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 + "/";
      }
   }
   break;
</javascript>
Maybe my jQuery ajax function manipulate my html form data?