5.3 User.StoreFile
StoreFile(filename string, content []byte) (err error)
Given a
filename
in the personal namespace of the caller, this function persistently stores the givencontent
for future retrieval using the samefilename
.If the given
filename
already exists in the personal namespace of the caller, then the content of the corresponding file is overwritten. Note that, in the case of sharing files, the corresponding file may or may not be owned by the caller.The client MUST allow
content
to be any arbitrary sequence of bytes, including the empty sequence.Note that calling
StoreFile
after malicious tampering has occurred is undefined behavior, and will not be tested.Returns an error if:
- The write cannot occur due to malicious action.
- Parameters
-
filename (string) - the name of the file
content ([]byte]) - the contents of the file - Return
-
err (error)
Do not forget that your design must satisfy all requirements, including:
- Different users can store files using the same filename, because each user must have a separate personal file namespace.
- Overwriting the contents of a file does not change who the file is shared with.
- Users can have multiple active user sessions at once.