Skip to content

Conversation

@solracsf
Copy link
Member

@solracsf solracsf commented Aug 27, 2025

Try to fix #54669

Summary

Replaced the mime_content_type() call with Nextcloud’s internal APIs.

Checklist

@solracsf solracsf added bug 3. to review Waiting for reviews labels Aug 27, 2025
@solracsf solracsf added this to the Nextcloud 32 milestone Aug 27, 2025
@solracsf solracsf marked this pull request as ready for review August 27, 2025 07:13
@solracsf solracsf requested a review from a team as a code owner August 27, 2025 07:13
@solracsf solracsf requested review from ArtificialOwl, CarlSchwan, leftybournes, marcelklehr and susnux and removed request for a team August 27, 2025 07:13
@marcelklehr marcelklehr requested a review from julien-nc August 27, 2025 07:20
@solracsf solracsf changed the title fix(TaskProcessing): Use node path on mimeTypeDetector fix(TaskProcessing): Replace mime_content_type() with Nextcloud’s internal APIs Aug 27, 2025
@julien-nc
Copy link
Member

This does not work because the file name has no extension. We have to get the file content to guess the mimetype.
This could be done with $this->mimeTypeDetector->detectContent($node->getPath()); but it's tough to get the absolute path to the file.

The warning mentioned in #54669 does not prevent mime_content_type to work as far as I can see.

@solracsf
Copy link
Member Author

solracsf commented Aug 27, 2025

@julien-nc :

This does not work because the file name has no extension

Oh, good point 👍

This could be done with $this->mimeTypeDetector->detectContent($node->getPath()); but it's tough to get the absolute path to the file.

Since $node->fopen('rb') gives us a readable stream, maybe can we grab a small prefix (e.g. 8 KB) and run detectContent() on it?

The warning mentioned in #54669 does not prevent mime_content_type to work as far as I can see.

Or are you suggesting to just @ silence it and move on?

@solracsf solracsf added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Aug 27, 2025
@julien-nc
Copy link
Member

julien-nc commented Aug 27, 2025

detectContent() takes a path as input, you can't use the stream or a portion of it unless you write it to a temp file.

Or are you suggesting to just @ silence it and move on?

I think it's fine like it is now.
Can we silence the warning log?

@julien-nc
Copy link
Member

Confirmed in the issue. It's working fine.
We could either silence the warning log (if possible) or reduce its log level to 1 (info).

@solracsf

This comment was marked as outdated.

@julien-nc

This comment was marked as outdated.

@solracsf
Copy link
Member Author

or reduce its log level to 1 (info).

Lowered to info as per your suggestion.

@solracsf solracsf changed the title fix(TaskProcessing): Replace mime_content_type() with Nextcloud’s internal APIs fix(TaskProcessing): Log mime_content_type() failure at info level Aug 27, 2025
This was referenced Aug 28, 2025
@julien-nc
Copy link
Member

According to the logs, I'm not sure there is an exception thrown. It's just a log line written by Icewind\\Streams\\CallbackWrapper when its stream_cast method is called. We don't have control over this log production in TaskProcessingApiController.

@solracsf solracsf closed this Sep 3, 2025
@solracsf solracsf deleted the nodePathMimeType branch September 3, 2025 23:31
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: mime_content_type(): Icewind\\Streams\\CallbackWrapper::stream_cast is not implemented

4 participants