-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d9b3b4
commit 0209a87
Showing
6 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCP\Files\Conversion; | ||
|
||
use JsonSerializable; | ||
|
||
/** | ||
* A tuple-like object representing both an original and target | ||
* MIME type for a file conversion | ||
* | ||
* @since 31.0.0 | ||
*/ | ||
class ConversionMimeTuple implements JsonSerializable { | ||
/** | ||
* @param string $from The original MIME type of a file | ||
* @param list<array{mime: string, name: string}> $to The desired MIME type for the file mapped to its translated name | ||
* | ||
* @since 31.0.0 | ||
*/ | ||
public function __construct( | ||
private string $from, | ||
private array $to, | ||
) { | ||
} | ||
|
||
/** | ||
* @return array{from: string, to: list<array{mime: string, name: string}>} | ||
* | ||
* @since 31.0.0 | ||
*/ | ||
public function jsonSerialize(): array { | ||
return [ | ||
'from' => $this->from, | ||
'to' => $this->to, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCP\Files\Conversion; | ||
|
||
use OCP\Files\File; | ||
|
||
/** | ||
* @since 31.0.0 | ||
*/ | ||
interface IConversionManager { | ||
/** | ||
* Determines whether or not conversion providers are available | ||
* | ||
* @since 31.0.0 | ||
*/ | ||
public function hasProviders(): bool; | ||
|
||
/** | ||
* Gets all supported MIME type conversions | ||
* | ||
* @return list<ConversionMimeTuple> | ||
* | ||
* @since 31.0.0 | ||
*/ | ||
public function getMimeTypes(): array; | ||
|
||
/** | ||
* Convert a file to a given MIME type | ||
* | ||
* @param File $file The file to be converted | ||
* @param string $targetMimeType The MIME type to convert the file to | ||
* @param ?string $destination The destination to save the converted file | ||
* | ||
* @return string Path to the converted file | ||
* | ||
* @since 31.0.0 | ||
*/ | ||
public function convert(File $file, string $targetMimeType, ?string $destination = null): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCP\Files\Conversion; | ||
|
||
use OCP\Files\File; | ||
|
||
/** | ||
* This interface is implemented by apps that provide | ||
* a file conversion provider | ||
* | ||
* @since 31.0.0 | ||
*/ | ||
interface IConversionProvider { | ||
/** | ||
* Get an array of MIME type tuples this conversion provider supports | ||
* | ||
* @return list<ConversionMimeTuple> | ||
* | ||
* @since 31.0.0 | ||
*/ | ||
public function getSupportedMimeTypes(): array; | ||
|
||
/** | ||
* Convert a file to a given MIME type | ||
* | ||
* @param File $file The file to be converted | ||
* @param string $targetMimeType The MIME type to convert the file to | ||
* | ||
* @return resource|string Resource or string content of the file | ||
* | ||
* @since 31.0.0 | ||
*/ | ||
public function convertFile(File $file, string $targetMimeType): mixed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCP\Share\Exceptions; | ||
|
||
use Exception; | ||
|
||
/** | ||
* @since 31.0.0 | ||
*/ | ||
class ShareTokenException extends Exception { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters