# Import all files in a user's local directory using Wolfram Cloud?

Posted 1 month ago
188 Views
|
0 Replies
|
1 Total Likes
|
 I have written a FormFunction which takes a folder path as it's input, I refer to this path as the vault. The function goes through all files in the vault (and it's subfolders), and imports all .md files as "Text". It then does some parsing of the files to eventually create a graph of the links between the files. This works fine on my local pc. The problem arises when I try to deploy the form to the Wolfram Cloud.I want users to be able to input the absolute path of their local vault and have the function run on their machine. I have tried the following FormFunction[{"vault" -> "Directory"}, ...], but this doesn't get past the input stage. When I run the form, the input box for vault has a Browse... button as intended, but when I actually select a folder to use as vault, it just goes inside that folder but doesn't let me choose it as input for the form.I have also tried FormFunction[{"vault" -> "String"}, ...], intending for users to type out the absolute path to their vault as a string. But when I run the cloud deployed form, it doesn't evaluate.Is there a way I can do this in the way I am trying? Is it possible to Import multiple files from Wolfram Cloud? All I need to run the function is the plain text of each Markdown file in the vault.Here is the Form I am trying to run: FormFunction[ {"vault" -> "Directory"}, isolateLinkContent[filePath_String] := StringCases[ Import[filePath, "Text"], RegularExpression["\$\\[(.*?)\$\\][^]"] -> "\$1"]; splitLinkContent[filePath_String] := StringSplit[isolateLinkContent[filePath], {"#","#^", "\\", "|"}]; notesLinkedTo[filePath_String] := Union[splitLinkContent[filePath][[All, 1]]]; noteEdges[filePath_String] := Module[ {noteTitle = FileBaseName[FileNameTake[filePath]], internalLinks = notesLinkedTo[filePath]}, Thread[noteTitle \[UndirectedEdge] internalLinks]]; Module[ {allFilePaths, allFileNames, allEdges}, allFilePaths = FileNames["*.md", #vault, Infinity]; allFileNames = FileBaseName[FileNameTake[#]] & /@ allFilePaths; allEdges = Flatten[noteEdges /@ allFilePaths]; Graph[ allFileNames, allEdges, VertexSize -> 0.4]] &] `