Skip to content

CAMEL-22686 Add handling of a GenericFile body to DoclingProducer.getInputPath()#19892

Merged
davsclaus merged 1 commit intoapache:mainfrom
cunningt:CAMEL-22686
Nov 19, 2025
Merged

CAMEL-22686 Add handling of a GenericFile body to DoclingProducer.getInputPath()#19892
davsclaus merged 1 commit intoapache:mainfrom
cunningt:CAMEL-22686

Conversation

@cunningt
Copy link
Contributor

Description

Add handling of a GenericFile case to DoclingProducer.getInputPath - it would allow going directly from camel-file to camel-docling.

Target

  • [x ] I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • [x ] If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • [x ] I checked that each commit in the pull request has a meaningful subject line and body.

  • [x ] I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

@github-actions
Copy link
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟

🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run

  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot.

  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.

  • Build and test logs are available in the Summary page. Only Apache Camel committers have access to the summary.

  • ⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@davsclaus
Copy link
Contributor

You dont need to add camel-file as dependency, but you can check for wrapped file ala

        if (obj instanceof WrappedFile<?> wf) {
            obj = wf.getFile();
        }
        if (obj instanceof File f) {
            filePayload = f;
            inputStream = new FileInputStream(f);
            contentLength = f.length();

You can see how this is done elsewhere such as above from aws, or do a git grep WrappedFile to find code samples.

Copy link
Contributor

@davsclaus davsclaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comments

@cunningt
Copy link
Contributor Author

You dont need to add camel-file as dependency, but you can check for wrapped file ala

        if (obj instanceof WrappedFile<?> wf) {
            obj = wf.getFile();
        }
        if (obj instanceof File f) {
            filePayload = f;
            inputStream = new FileInputStream(f);
            contentLength = f.length();

You can see how this is done elsewhere such as above from aws, or do a git grep WrappedFile to find code samples.

Sorry about that - removed the camel-file dependency and used WrappedFile.

validateFileSize(file.getAbsolutePath());
return file.getAbsolutePath();
} else if (body instanceof WrappedFile<?> wf) {
File file = (File) wf.getFile();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot type cast directly to File, as WrappedFile can also come from FTP and then its another kind, or azure file that is also type etc. So you need to do
Object f = wf.getFile
if (f instanceof File file) ...

@davsclaus davsclaus merged commit 8e671d7 into apache:main Nov 19, 2025
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants