Convert a string to a url to find files in a folder

Dear community.

I have to retrieve an image file from a folder in the file system (Mac / Servoy 7). The image is in a folder with a uuid as a name (the folders come from an export from Bento). The folders each have exactly one image in them. I know the path to the file and have stored that in a Servoy dataprovider, and it looks something like this: /Users/bevil/Desktop/My\ Client\ Export/Bento\ Backup\ -\ 2015-05-04.bentodb/Assets/3C433D40-B895-4816-A3F2-04A93D197C53/

I don’t know the name of each image file in that folder, so I need something like file.getFolderContents() to turn the files into an array.

However I do not know how to turn my url (a string) into a path that Servoy can read, and thus look in the folder to find the files.

Any help would be appreciated…

Bevil

According to the documentation this should work:

plugins.file.getFolderContents(<YOUR_DATAPROVIDER>)

It returns a JSFile array.

Hi,

The path :

/Users/bevil/Desktop/My\ Client\ Export/Bento\ Backup\ -\ 2015-05-04.bentodb/Assets/3C433D40-B895-4816-A3F2-04A93D197C53/

If you are using this path directly without formatting the path, then it would fail I guess. The above path contains both type of slashes. So you need to use ‘/’ (for Mac).
Just format the path and pass it in plugins.file.getFolderContents(path) as stated by Marc.

You might be formatting it before use, but I saw this path here so posted… Might be the trick here!

With that kind of a path the file streaming default folder needs to be set to the operating system root (“/” or “C:\”) in the plugin’s admin page. A bunch of example file streaming code: http://community.data-sutra.com/project … am.js#L136

sovanm:
Hi,

The path :

/Users/bevil/Desktop/My\ Client\ Export/Bento\ Backup\ -\ 2015-05-04.bentodb/Assets/3C433D40-B895-4816-A3F2-04A93D197C53/

If you are using this path directly without formatting the path, then it would fail I guess. The above path contains both type of slashes. So you need to use ‘/’ (for Mac).
Just format the path and pass it in plugins.file.getFolderContents(path) as stated by Marc.

You might be formatting it before use, but I saw this path here so posted… Might be the trick here!

The backslashes are identified as escape characters for the subsequent spaces. This does work as a data path per Mac file system (if I do in terminal: ‘open /Users/bevil/Desktop/My\ Client\ Export/Bento\ Backup\ -\ 2015-05-04.bentodb/Assets/3C433D40-B895-4816-A3F2-04A93D197C53/’ it does open that folder in the finder.)… I don’t think it is a formatting issue, I think it is a question of it being interpreted as a string rather than as a file object…

mboegem:
According to the documentation this should work:

plugins.file.getFolderContents(<YOUR_DATAPROVIDER>)

It returns a JSFile array.

Thank you Marc. I never thought of that. I think that might be my answer… Many thanks…