From ba61c6435b668375a411716f3a35447aa38b03a4 Mon Sep 17 00:00:00 2001 From: winter Date: Sat, 18 Jan 2025 00:22:36 +0000 Subject: implement object storage --- Digitigrade/StorageProvider.php | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Digitigrade/StorageProvider.php (limited to 'Digitigrade/StorageProvider.php') diff --git a/Digitigrade/StorageProvider.php b/Digitigrade/StorageProvider.php new file mode 100644 index 0000000..53b3549 --- /dev/null +++ b/Digitigrade/StorageProvider.php @@ -0,0 +1,62 @@ +storeFileInternal($path); + } + + abstract protected function storeFileInternal(string $path): ?string; + + /** + * @param string $token the token of the object to look for + * @return bool whether the requested object exists or not + */ + abstract public function exists(string $token): bool; + + /** + * Retrieves an object's contents from the storage backend. + * @param string $token the token of the object to retrieve + * @return ?string the entire content, or null if not found + */ + abstract public function retrieve(string $token): ?string; + + /** + * Gets a direct, public URL to the given object, if possible. + * @param string $token the token of the object to look up + * @return ?string the URL or null if one is not available + */ + abstract public function directUrl(string $token): ?string; + + /** + * Streams the data of an object to the web client (stdout). + * @param string $token the token of the object to retrieve + * @param ?string $mimetype value of the Content-Type header to send (if + * null, will try to figure it out anyway) + * @return void + */ + abstract public function passthrough(string $token, ?string $mimetype = null); + + /** + * Deletes an object from the backend. If the object doesn't exist, does + * nothing. + * @param string $token the token of the object to delete + * @return void + */ + abstract public function delete(string $token); +} \ No newline at end of file -- cgit v1.3