AnsweredAssumed Answered

How to set title and description on REST file upload?

Question asked by driekhof on Mar 3, 2016
Latest reply on Dec 27, 2016 by picoalfro
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);
      }
   }

Outcomes