-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] feat: file conversion provider #49922
base: master
Are you sure you want to change the base?
Conversation
7e8ed84
to
3ab63cb
Compare
|
||
public function getSupportedMimeTypes(): array { | ||
$jpegConversions = new ConversionMimeTuple('image/jpeg', [ | ||
'image/png', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something just came to my mind is that for integrating the user interface we may also want additional metadata for the target formats.
We can probably get the file extension from our mimetype mapping, but wondering if we need to have more details, like a display name. Similar to save dialogs that came to my mind:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sorbaugh Has the files team already discussed any UI parts with designers? I'd say we can start with this PR and could extend/adapt on demand later on as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I literally added a similar comment eheh
Two options I think:
- We stop using
getSupportedMimeTypes
and go back to a singulargetSupportedMimeType
, and we basically use the name, only one Provider per destination mime - We turn this into a
mime => l10n
array, so we know the end name of each mime :)
b1d9670
to
1bceac6
Compare
2cdd54b
to
e91c447
Compare
if (!($file instanceof File)) { | ||
throw new OCSNotFoundException(); | ||
} | ||
|
||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also check the parent folder CREATE permissions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point. I just did some testing by sharing a view-only folder with a document in it to another user, and it will already throw an OCP\Files\NotPermittedException
if it cannot write to the destination (L122), which then returns something like this in the network response via an OCSException
:
{
"ocs": {
"meta": {
"status": "failure",
"statuscode": 999,
"message": "Could not create path \"/alice/files/Bobs_Shared_Folder/converted_file.pdf\""
},
"data": []
}
}
I can still implement an explicit check if necessary, though. What do you think? It could also be that my error handling here isn't the best or obvious enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can still implement an explicit check if necessary, though
I am usually in favour of clear sanity checks.
Because if something breaks/changes in the following methods, we'll have no way of knowing it.
* | ||
* @since 31.0.0 | ||
*/ | ||
public function getName(): string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
I think the name of the end format is more relevant.
Signed-off-by: Elizabeth Danzberger <[email protected]>
Co-authored-by: Kate <[email protected]> Signed-off-by: Elizabeth Danzberger <[email protected]>
Signed-off-by: Elizabeth Danzberger <[email protected]>
Signed-off-by: Elizabeth Danzberger <[email protected]>
Signed-off-by: Elizabeth Danzberger <[email protected]>
877231a
to
2d7a803
Compare
Summary
This PR will introduce a file conversion API endpoint, which can be called to convert a file from one type to another. Apps can register their own conversion providers (which implement
IConversionProvider
), and the providers can define which MIME types they support for conversion viaConversionMimeTuple
s.TODO
IConversionProvider
interfaceChecklist