Search code examples
javaibm-cloud-infrastructureobject-storage

Cannot get the file list in SoftLayer's Object Storage


We operate SoftLayer's Object Storage with this Java library. https://github.com/softlayer/softlayer-object-storage-java/tree/master/sl-objectstorage 「sl-objectstorage.jar」 「com.softlayer.objectstorage.Account」-「search」method

When we would like to get the file list in the container, we can get the file list which is uploaded and saved before 1st Dec 2016 but we cannot get the file list which is saved after 1st Dec 2016 at all.

Do you have any resolution for this kind of problem?


Solution

  • Apparently, there is an issue with search method in some datacenters. e.g: ams01.

    We are reporting the issue, but it should be good to open a ticket to track this (Attach this forum). Anyway if there will be a fix, we will let you know any news in this thread.


    Updated

    It can be a workaround:

     public static void main(String[] args) throws IOException, EncoderException {
    
            /**
             * Define Object Storage Account information
             */
            String baseUrl = "https://tok02.objectstorage.softlayer.net/auth/v1.0/";
            String user = "set me";
            String password = "set me";
            Account account = new Account(baseUrl, user, password);
            // Define your container's name
            String containerName = "r";
    
            List<Container> containers = account.listAllContainers();
            for (Container container: containers){
                if(container.getName().contains(containerName))
                {
                    System.out.println("Container: " + container.getName());
                    for(ObjectFile file : container.listObjectFiles())
                    {
                        System.out.println("File Name: " + file.getName());
                        System.out.println("Bytes: " + file.getBytes());
                        System.out.println("Meta Tags: " + file.getMetaTags());
                    }
                    System.out.println("==================================");
                }
            }
         }
    

    Also, you can change this line:

                if(container.getName().contains(containerName))
    

    to:

                if(container.getName().equal(containerName))
    

    To get an exact match for the container name

    I hope it can help you.