cancel
Showing results for 
Search instead for 
Did you mean: 

How to set title and description on REST file upload?

driekhof
Champ in-the-making
Champ in-the-making
I've tried both Jersey and Apache Commons HTTP client.  I can upload a file to a site's document library to a particular folder, but I can't figure out how to get it to set the 'title' and 'description' properties.

Here's  my latest try, see anything wrong?  The response looks good, 200, or errors.  It's just ignoring what I send for description and title.

Using 5.0.3.


   public void uploadDocument(String ticket, File fileobj,
         String site, String desc, String title,
         String destination) {
      try {

         String urlString = uriRepoApi + "upload?alf_ticket="
               + ticket;
         logger.info("The upload url:::" + urlString);
         HttpClient client = new HttpClient();

         PostMethod mPost = new PostMethod(urlString);

         Part[] parts = {
               new FilePart("filedata", fileobj),
               new StringPart("filename", fileobj.getName()),
               new StringPart("description", desc),
               new StringPart("title", title),
               new StringPart("siteid", site),
               new StringPart("containerid", "documentLibrary"),
               new StringPart("uploaddirectory", destination)
         };
         mPost.setRequestEntity(new MultipartRequestEntity(parts, mPost
               .getParams()));
         
         int statusCode1 = client.executeMethod(mPost);
         logger.info("statusLine>>>" + statusCode1 + "……"
               + "\n status line \n"
               +mPost.getStatusLine() + "\nbody \n" +mPost.getResponseBodyAsString());
         mPost.releaseConnection();

      } catch (Exception e) {
         System.out.println(e);
      }
   }

2 REPLIES 2

driekhof
Champ in-the-making
Champ in-the-making
After a lot of stumbling and bumbling around, I finally found that apparently you can't set these properties with the Repository API, but you can with the CMIS REST API.

After a lot more stumbling and bumbling, I finally got some CMIS code working on 5.0.3 to upload with title and description set.  I can post the code if anyone is interested.

Now I just need to figure out how to tag each of these uploaded files with a few keywords.  I had that working using the Repo API, but it was depending on the response to get the noderef.  Hopefully it won't be too difficult to tag these files uploaded with CMIS.

picoalfro
Champ in-the-making
Champ in-the-making

Please post the code of setting title and description on REST file upload (versin 4.2)