5.4. User.LoadFile: Load user files

Implement this method:

LoadFile(filename string) (data []byte, err error)

If the file does not exist, return an error.

If the file exists, download the latest version of the file. If loading the file cannot complete due to some malicious action, return an error.

Verify the integrity of the downloaded file. If there have been any unauthorized modifications to the file, then return an error.

If the file could be downloaded and its integrity was verified, then return the contents of the file.

Parameters
  • filename (string) – File name

  • data ([]byte) – File contents

Return type

[]byte, error

Warning

Do not forget that your design must satisfy all requirements, including:

  1. Users can have multiple active user sessions at once (see User Sessions).