2.2.4. AppendFile
Implement this function:
- User.append_file(filename: str, new_data: bytes)
Efficiently appends
new_data
to the end of the file namedfilename
that is owned by the calling user. However, raises autil.DropboxError
in the following circumstances:If no file named
filename
exists.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.Set
anddataserver.Get
) must scale linearly in the size of the data being appended and the number of usersfilename
is 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_file
operation tofilename
should not use significantly more bandwidth than the firstappend_file
operation. (This is not an exhaustive list of examples.)