Home
File Storage
Home
File Storage
This module allows you to store/retrieve files that are automatically encrypted.
If SelfGuard was instantiated with a key pair, it will automatically encrypt files such that only the owner of the key pair will be able to access the file.
If SelfGuard was instantiated with metamask, it will automatically encrypt files such that only the owner of the metamask account will be able to access the file. Furthermore, it will use Lit Protocol to store the encryption keys, ensuring the encryption keys can only be retrieved by the owner of the respective metamask account.
Encrypt File
This allows you to encrypt files and upload them to the cloud.
filerequired
File | string
If sg
was instantiated with selfguard-client
then file
will be a javascript web File object.
If sg
was instantiated with selfguard-node
then file
will be the file_path of the file.
callbackrequired
function
callback function that will be called with two paramaters err
and value
where value
will equal the progress of the file upload & encryption.
await sg.encryptFile(file, callback);
Decrypt File
This allows you to decrypt a file that was uploaded with SelfGuard.
file_idrequired
string
The id of the file that was encrypted.
callbackrequired
function
callback function that will be called with two paramaters err
and value
where value
will equal the progress of the file download & decryption.
await sg.decryptFile(file_id, callback);
Get Files
This allows you to get the file names and ids of the uploaded files
await sg.getFiles();