The code in this repository allows you to spin up a canister on the internet computer that handles file storage and serving over https.
One of the unique features is that you can deploy websites as you would do in an traditional web2 FTP setting (ex; filezilla). Just by uploading files you can serve a website on a canister that could also handle backend logic.
This canister serves as an example. If the index.html
file would be removed, the file manager frontend would not be reachable.
The repository for the file manager frontend can be found here.
For the purpose of this demo all files and directories have an owner
, you can add and delete files and folders to the directories that you own. When adding files with an anonymous principal it is possible for other people to delete the files and / or directories.
making this canister user controlled can be done by using the owner
or introducing a whitelist
to authenticate calls.
- make sure you have DFX installed
- navigate to the backend folder with a CLI
- run
dfx start --clean --background
- run
dfx deploy --no-wallet
- Move to stable storage(!)
- Implementation of access control for serving over http(s), basis is set but not integrated
- Improve fallback like serving a
404
, right now everything falls back to theindex.html
which can cause the frontend to function incorrectly if a file does not exist - improve data access control / integrate canister owner
- add optional default index page where files and directories are displayed when visiting a directory as with default (unsecured) webservers
- combine
get_file_by_path
andget_file_path
methods - overal code cleanup
- Specific access control (permissions) does not work, (making files available from
https://canister-id.raw.ic0.app
but but not fromhttps://canister-id.raw.ic0.app/image1.png
whenPermission::Private
is specified). The ideal approach would be to use http headers to control this but this does not seem to work. An other way would be to throw a404
when visiting the url directly and add methods for fetching the chunks manually and create the file on the frontend. (http_methods.rs:150
)