File path to URL

Hi

Does somebody know if there is a way to get an URL from a file path?

I need to provide an URL as a variable to the csv.reader node but I I only have the file path.

I have found the URL to file path node but not the reverse one.

Best Regards

Loys

Hi Loys,

The easiest option is to use a File Upload Quickform node which creates two variables for the selected file. One represents a file path and the other a URL. Connect the node's flow variable outport to the flow variable inport of the csv reader node and configure the csv reader node to use the URL variable.

If you don't want to use a quickform node, another option is to use a Java Snippet node (or Java Edit Variable node) to convert an existing file path to a URL. Both approaches are given in the attached workflow. If I had more time, I might look into handling errors, etc.

Hope this helps.

-Don

Hi Don

Thanks a lot  for your reply.

I tried both solutions and the Java snippet you provided is working fine for my case , on the other hand , the File Quickform node does not work as I already have the filename in a variable and it looks that I cannot use this variable as an input variable for this node.

Best Regards

Loys

I am surprised that there is a “URL to FilePath” node but not a “FilePath to URL” node…
There is a “String to URI” node but the formatting of the URL string should still be done “manually”…

In my case, I need to convert a column of filepath to their URL equivalent, I am not much of a Java programmer so I would go for python.

Actually if you provide the String to URI node with an file path it will create a file:/ uri.
You need to ensure yourself though that the path is absolute.
best,
Gabriel

1 Like

My mistake sorry I though I had an issue with my path but it works as a charm thanks