/**
  * Resume the Download of a File
  *
  * @param urld - required -
  *          The download URL.
  * @param dir - required -
  *          The download folder (path+folderName).
  * @param password - optional -
  * 	  If a password has been set, the recipients are asked to enter the password before they can access the files. The minimum length of the password is 5 characters.
  * @param range - optional -
  * 	  Only the specified range of bytes is downloaded and appended to the existing file if a range has been set. If no range has been set the entire file is downloaded and saved inside the download directory (the value from $dir).
  * @return The status "fail" if the download has failed or the downloaded file name if the download has succeeded.
  * 	 */
 public function downloadaFileResume($urld, $dir, $password = '', $range = '')
 {
     $parameters = array();
     if ($password !== '') {
         $parameters['password'] = $password;
     }
     $a = new DownloadFile($this->_hostName, $this->_apiKey, $this->_userAgent);
     $response = $a->sendRequestWS($urld, $parameters, $this->_authToken);
     if ($response !== 'fail') {
         $s = strpos($response, "Location: ") + 10;
         $e = strpos($response, "Server:") - 2;
         $d = $e - $s;
         $url = substr($response, $s, $d);
         $response = $a->sendRequestResume($url, $this->_authToken, $range);
         if ($response !== 'fail') {
             $s = strpos($url, "&file=") + 6;
             $e = strlen($url);
             $d = $e - $s;
             $fname = substr($url, $s, $d);
             $f = $dir . $fname;
             if ($range[0] == '0' || ($range = '')) {
                 file_put_contents($f, $response);
             } else {
                 $fh = fopen($f, 'a');
                 fwrite($fh, $response);
                 fclose($fh);
             }
             return $fname;
         } else {
             return 'fail';
         }
     } else {
         return 'fail';
     }
 }