cancel
Showing results for 
Search instead for 
Did you mean: 

Read file from SLDB?

j_angelevski
Contributor III

Hi,

I am in the process of building a custom snap and I am uncertain of how to read a file from the SLDB. The documentation does not provide an example for this. I was able to read a file from the location where the Groundplex is, using the com.snaplogic.common.url.protocol.file.FileUrlConnection class, but I am unsure of how to accomplish the same thing for a file stored in the SLDB.

@ptaylor Any suggestions on this ?

1 ACCEPTED SOLUTION

ptaylor
Employee
Employee

Use the com.snaplogic.common.utilities.URLEncoder class. It would look something like this:

            URLConnection urlConnection = new URLEncoder()
                    .validateAndEncodeURI(path)
                    .toURL().openConnection();
            urlConnection.connect();
            try (InputStream inputStream = urlConnection.getInputStream()) {
                // ...
            }

View solution in original post

2 REPLIES 2

ptaylor
Employee
Employee

Use the com.snaplogic.common.utilities.URLEncoder class. It would look something like this:

            URLConnection urlConnection = new URLEncoder()
                    .validateAndEncodeURI(path)
                    .toURL().openConnection();
            urlConnection.connect();
            try (InputStream inputStream = urlConnection.getInputStream()) {
                // ...
            }

j_angelevski
Contributor III

@ptaylor

Thanks, Patrick, this was the solution I was looking for.