Skip to Main Content

Cloud Platform

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unable to display images stored in the MCS Storage Collections, by providing the URI of the storage

Vidhya Valantina VenkateshJul 25 2017 — edited Jul 27 2017

Unable to display images stored in the MCS Storage Collections, by providing the URI of the storage collection. Please help me with this requirement. I had earlier tried to do a workaround, but then, now I need to retrieve images for a list of items that are obtained in a JSON, I tried doing this, using the below,

for (var index = 0; index < itemsJson.length; index++){

            itemImgName = itemsJson[index].itemPartNumber + ".png";

            console.fine("Image Name to be searched " + itemImgName );

            item = itemsJson[index];

            console.fine("Obtain Item Image for" +  itemImgName );

            sdk.storage.getById( imageCollection

                                ,itemImgName ).then(

                function(result){

                    console.fine("Image Obtained.");

                    item.itemImage = result.result;

                },

                function(error){

                    console.fine(error.statusCode+error.error);

                }

            );

        }

// At the end of the for loop, I would need to store the entire itemsJson into MCS Storage back. using the Storage API.

However, due to node.js, being asynchronous, the itemsJson is stored to MCS Storage even before the getById completes for all the items in the for loop.

I tried using callbacks also, but nothing seems to work when trying to process within a for loop.

Please help. This is urgent for me.

This post has been answered by User_HWHT9 on Jul 25 2017
Jump to Answer
Comments