-
-
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
feat: file conversion provider #49922
base: master
Are you sure you want to change the base?
Conversation
7e8ed84
to
3ab63cb
Compare
b1d9670
to
1bceac6
Compare
2cdd54b
to
e91c447
Compare
877231a
to
2d7a803
Compare
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]>
ac0843f
to
e8d3eac
Compare
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.
Very nice! I only have a few smaller things to not, feel free to ignore the most nit picky ones 😅
|
||
// Operate in mebibytes | ||
$fileSize = $file->getSize() / (1024 * 1024); | ||
$threshold = $this->config->getValue('max_conversion_filesize', 100); |
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.
Wouldn't it make sense to also check that the threshold is a sensible value? Otherwise an admin might configure something like 100 GiB and break their instance. I'm not sure what a reasonable limit is, especially when it comes to high resolution photos or long (high resolution) videos.
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 don't see a risk of breaking the instance here. If an admin configures long timeouts then it should be fine. At some point we may rather want to have background workers that do an async conversion so we don't run into timeouts (which is the main reason for adding this), but this was discussed out of scope due to the short-term scheduling with @AndyScherzinger.
Signed-off-by: Elizabeth Danzberger <[email protected]>
Signed-off-by: Elizabeth Danzberger <[email protected]>
Signed-off-by: Elizabeth Danzberger <[email protected]>
e8d3eac
to
23e4606
Compare
Signed-off-by: Elizabeth Danzberger <[email protected]>
@@ -38,6 +41,10 @@ public function getCapabilities(): array { | |||
'max_size' => ChunkedUploadConfig::getMaxChunkSize(), | |||
'max_parallel_count' => ChunkedUploadConfig::getMaxParallelCount(), | |||
], | |||
|
|||
'file_conversions' => array_map(function (ConversionMimeTuple $mimeTuple) { | |||
return $mimeTuple->jsonSerialize(); |
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.
It looks like this part is failing to serialize to xml in the integration tests, but have not checked locally, so not sure what the best way to fix this is.
{
"reqId": "6YTbALAvT2hTLsT4X3ec",
"level": 3,
"time": "2025-01-14T22:43:50+00:00",
"remoteAddr": "::1",
"user": "admin",
"app": "PHP",
"method": "GET",
"url": "/ocs/v1.php/cloud/capabilities",
"message": "ValueError: XMLWriter::writeElement(): Argument #2 ($content) must be a valid element name, \"image/png\" given at /home/runner/actions-runner/_work/server/server/lib/private/AppFramework/OCS/BaseResponse.php#149",
"userAgent": "GuzzleHttp/7",
"version": "31.0.0.9",
"data": {
"app": "PHP"
}
}
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.
Hm yeah that is tricky, seems like /
is forbidden as tag name (makes sense since it is part of the XML syntax).
The output format could be changed so that it's no longer used as a key but the entire data structure is a list and the source format is just a property of the objects in the list.
As a followup, it would be nice to add some integration tests.
|
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