2.2.4. AppendFile
Implement this function:
- User.append_file(filename: str, new_data: bytes)
Efficiently appends
new_datato the end of the file namedfilenamethat is owned by the calling user. However, raises autil.DropboxErrorin the following circumstances:If no file named
filenameexists.File appending cannot complete due to malicious action. (This operation is not required to verify the integrity of the existing file data for
filename, but it is allowed to perform such checks and raise an error if malicious action has been detected.)
“Efficiently” means that this operation’s bandwidth (as measured by the total size of the data uploaded and downloaded via
dataserver.Setanddataserver.Get) must scale linearly in the size of the data being appended and the number of usersfilenameis shared with, and nothing else}. Logarithmic and constant scaling in other terms is acceptable.- Parameters:
filename (str) – The name of the file
new_data (bytes) – The data to append to the end of the existing file
- Returns:
nothing
- Raises:
DropboxError – if an error case occurred
Note
Some examples of efficiency requirements: appending 100 bytes to a 10 terabyte file should not use 10 terabytes of bandwidth; similarly, the 1000th
append_fileoperation tofilenameshould not use significantly more bandwidth than the firstappend_fileoperation. (This is not an exhaustive list of examples.)