Hitachi Content Platform​

 View Only

 Are there examples of putting and getting objects from HCP using xmlhttprequest (or other browser ajax call)?

  • General
  • Development
  • Object Storage
  • Hitachi Content Platform HCP
Jared Lewis's profile image
Jared Lewis posted 02-19-2021 19:52

I'm trying to build a page that will let people upload and download from HCP without their using the HCP interface. This will allow us to put other checks around whether they're able to view a particular document. I seem to be able to Put the file into HCP alright, but whenever I get it, it's coming to me in a format I can't successfully convert to a file the browser will 'download' successfully.

Javier Avila Nieto's profile image
Javier Avila Nieto

Hi Jared,


I've created the following example to upload a file using an Ajax function to HCP. It works fine in my lab, hopefully you can use this example to resolve the issue in your environment.








  <title>Javito HCP test - Upload file</title>

  <meta charset="utf-8">

  <script src="js/jquery-3.5.1.min.js"></script>





  <form id="formuploadajax" method="post" >


   <input type="file" id="archivo1" name="archivo1"/>

   <input type="submit" value="Upload File" name="submit">





     $("#formuploadajax").on("submit", function(e){



       var file = $('#archivo1')[0].files[0];



         url: "http://javito.javito.hcp.javito.lab/rest/" +,

         type: "PUT",

         headers: ({"Authorization": "HCP YWRtaW4=:1aa4c4552dbb438d9d46c15d93bbbbbf"}),

         data: file,

         cache: false,

         contentType: false,

         processData: false,

         success: function (data) {

          alert("Upload OK");


         error: function(err){

          alert("Upload Failed");









Jared Lewis's profile image
Jared Lewis

Thanks, @Javier Avila Nieto​! That's more information than I was able to previously find online. Hopefully it helps other as well. Has anyone had success pulling files via ajax that had been uploaded in this manner? I've had no success and can't tell if it's an order of operations thing (need to base64 it before/after something else) or I'm over complicating things (maybe I don't need to convert to a byte array). I've been trying lots of varieties, including just returning what comes to be via the get.