This PR fixes a bug that the client library should not download the file if the file exists and overwrite=False. Previosly, it downloads the file first, then checks if the file exists, which wastes bandwidth.
By using stream=True parameter, the requests method can postpone the download. saveAsFile will handle the actual stream download, and also return the download time and file size.
Initially I tried using HEAD first to avoid the download. Turns out it requires a bigger code change (download the file in status=200 branch). I also met some difficulties like HEAD does not have a body, so status=202 cannot use response.json(). Using stream can keep the current code logic unchanged.
The test failure can be ignored. It is a backend bug, which will be fixed in the backend later.
This PR fixes a bug that the client library should not download the file if the file exists and overwrite=False. Previosly, it downloads the file first, then checks if the file exists, which wastes bandwidth.
By using stream=True parameter, the requests method can postpone the download.
saveAsFile
will handle the actual stream download, and also return the download time and file size.Initially I tried using HEAD first to avoid the download. Turns out it requires a bigger code change (download the file in
status=200
branch). I also met some difficulties like HEAD does not have a body, sostatus=202
cannot use response.json(). Using stream can keep the current code logic unchanged.The test failure can be ignored. It is a backend bug, which will be fixed in the backend later.