Enable creating and modifying of FilesContainers within the SAFE Browser environment
- Status: proposed
- Type: new feature / enhancement
- Related components: safe-browser, safe-api, safe-nodejs
- Start Date: 2019-02-11
- Discussion: Enable creating and modifying of FilesContainers within the SAFE Browser environment
- Supersedes: (fill me in with a link to RFC this supersedes - if applicable)
- Superseded by: (fill me in with a link to RFC this is superseded by - if applicable)
Note: This RFC has been created as a pull request to the Maisafe RFC repository here, I have published this topic to get comments and feedback on the proposed API changes.
The NodeJS libraries work via the existing SAFE network CRUD conventions: we take files, we upload them to a network and generate an XORURL we can reference as a result. In the browser we do not have access to a native file sytem, so the underlying NodeJS libraries which the browser calls must allow the uploading of raw bytes, and the creation of empty FilesContainers.
- The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
At the moment, there is no browser native way to create an empty FilesContainer (since the previous convention was the creation of an NFS container which is no longer possible).
At the moment, the following API calls are available (and implemented in the NodeJS rust library) with regards to FilesContainers:
Logic would dictate that the browser would call
files_container_create to create the files container, however first argument to this method
location: &str requires a path to a directory or file which will be uploaded to the FilesContainer. The same issues also exist for
files_container_add_from_raw is usable.
I propose the addition of 1 new API to be added to the NodeJS library (and thereby allowed for use via the SAFE Browser):
This method will create an empty FilesContainer and return the XORURL of the created FilesContainer, or throw an Error.
It would make sense to implement this function here and expose it to the NodeJS libraries.
In NodeJS pseudocode, the interface would be:
function files_container_create_empty( bool dry_run ) : string;
The alternative is that FilesContainers can not be created from within the browser, which will significantly limit the abilities of SAFE browser native web apps.
The actual code needs to be written by the Maidsafe team.