Sunday, 8 July 2018

Code to retrieve an image from Oracle mobile cloud Storage collection

Calling the Storage API from Your App


Here’s code you can use to retrieve an image :

<html>
<body>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<img id="img" width=100%>


<script>
jQuery.ajax({
async: true,
  crossDomain: true,
  cache:false,
        url:'https://Your IDCS domain/mobile/platform/storage/collections/Your Collection name/objects/Your image object Id',
        method: "GET",
  headers: {
    authorization: "Your Mobile backend Authorization token",
    
'oracle-mobile-backend-id': "Your Mobile Backend ID"
   
},
xhr:function(){
            var xhr = new XMLHttpRequest();
            xhr.responseType= 'blob'
            return xhr;
        },success: function(data){
            var img = document.getElementById('img');
            var url = window.URL || window.webkitURL;
            img.src = url.createObjectURL(data);
        },
        error:function(){
            
        }
    });
</script>
</body>
</html>

No comments:

Post a Comment

Thanks for the comments. I`ll get back to you shortly.

Regards
Tushar