ropensci/prism

handle error when you try and download file too many times

rabutler-usbr opened this issue · 2 comments

If you try and download a file too many times you receive the following error txt file:

PRISM_tdmean_stable_4kmM3_1970_all_bil_error_msg_10.txt

RCurl::getURLContent(uri2) returns "application/zip" for a file that can be downloaded and "application/octet-stream" for the text file error message.

However, it uses up 1 of the downloads for the day. Ex: calling it three times will result in the third call returning the error text.


One idea - download as is normally done. If after unzipping the folder, the folder is empty, try renaming the zip folder to .txt, and then try scanning it as a text file. If you get expected text then print the message and delete the folder and zip file.

Implemented by using readLines() and checking to see if is PK\003\004, which indicates it's a zip. Otherwise posts warning and returns text that was read in.