Skip to content

Commit

Permalink
Store Company backup file directly to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Dec 2, 2023
1 parent fdee09d commit 011de98
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/AbraFlexi/Company.php
Expand Up @@ -164,23 +164,22 @@ public function rawResponseToArray(string $responseRaw, string $format)
*/
public function saveBackupTo($filename)
{
$result = false;
$backupFile = fopen($filename, 'w+');
$headersBackup = $this->defaultHttpHeaders;
$this->defaultHttpHeaders['Accept'] = '*/*';
$this->defaultHttpHeaders['Content-Type'] = 'application/x-winstrom-backup';
\curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, false); // return content as a string from curl_exec
\curl_setopt($this->curl, CURLOPT_FILE, $backupFile);
$responseCode = $this->doCurlRequest(
$this->evidenceUrlWithSuffix('backup'),
'GET',
'winstrom-backup'
);
fclose($backupFile);
$this->defaultHttpHeaders = $headersBackup;
if ($responseCode == 200) {
if (file_put_contents($filename, $this->lastCurlResponse)) {
$result = true;
}
}
$this->defaultHttpHeaders = $headersBackup;
return $result;
\curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true); // return content as a string from curl_exec
return $responseCode == 200;
}

/**
Expand Down

0 comments on commit 011de98

Please sign in to comment.