Skip to content

Commit

Permalink
Added creating files via webdav (Issue #98)
Browse files Browse the repository at this point in the history
  • Loading branch information
jswift committed Jan 7, 2022
1 parent b84eaa4 commit 56b3ae4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/BigCommerce/Files/BigCommerceFilesClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ private function buildDefaultHttpClient(): \GuzzleHttp\Client
self::DEFAULT_HANDLER => $stack,
self::DEFAULT_BASE_URI => $this->webdavPath,
'auth' => [$this->webdavUsername, $this->webdavPassword, 'digest'],
'http_errors' => false
'http_errors' => false,
'version' => 1.1,
]);
}

Expand All @@ -72,8 +73,17 @@ public function get(string $filename): ?string
}
}

public function put()
public function put(string $localFilename, string $targetFilename): bool
{
$file = fopen($localFilename, 'r');

if (!$file) return false;

$response = $this->client->put($targetFilename,
[
'body' => $file
]);

return $response->getStatusCode() === 201;
}
}

0 comments on commit 56b3ae4

Please sign in to comment.