I’d like to feed in this as a feature request, which if it is not hard to add would be great to see in a minor extension to the client API (as an extension to SAFE NFS and safe-js).
If we can have this I think it would find a lot of use within apps needing to store and load HTML, and make it very easy to implement file sharing with all SAFE apps which is one of the killer features of the internet: sharing user’s SAFE files via a public URL.
The aim is to be able to create a “safe:” URL for any file stored using SAFE NFS. A URL that beaker can directly interpret and load as part of a normal HTML page or as a file download link.
This would allow, for example, an image captured by a SAFE web app and stored in user’s SAFE NFS storage, to be loaded into a dynamic web page (the app) and displayed within the HTML UI of the app. Or a file generated by a web app could be saved to SAFE NFS, and a URL provided to the user which (if public data) could be passed to anyone using SAFE beaker in order to download the file.
Doing things this way makes it easy to port an existing app, of for someone who already knows how to create and load files on a traditional web server.
At the SAFE NFS API level, a web app would want to be able to provide an NFS file-path, including extension, so
/images/happybeing.jpg for example, and have returned a URL which beaker recognises as a hash based URL.
Given a reference to that URL in any HTML, or if pasted into the browser location bar, Beaker would recognise this URL as a SAFE hash URL and use it to access the file via the SAFE low level API, but return the content as if it was a normal file - i.e. with any necessary metadata (e.g. via headers or derived from a file extention that might be part of the URL - out of my depth here!).
Hope that makes sense!
There may be uses for accessing lower level SAFE data (i.e. not NFS files) through URLs but I’m not even going to try and think about the for now.
For reference, some notes about implementation from Ben’s post above: