Skip to content

Add hosting library for apache tika #578

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

Open
Meir017 opened this issue Mar 16, 2025 · 4 comments · May be fixed by #714
Open

Add hosting library for apache tika #578

Meir017 opened this issue Mar 16, 2025 · 4 comments · May be fixed by #714
Labels
awaiting response Waiting for the author of the issue to provide more information or answer a question good first issue Good for newcomers help wanted Extra attention is needed integration A new .NET Aspire integration

Comments

@Meir017
Copy link

Meir017 commented Mar 16, 2025

.NET Aspire issue link

dotnet/aspire#8100

Overview

Integrating with apache's Tika in dotnet isn't trivial and requires running https://github.com/apache/tika-docker

something like this:

public class TikaContainer(string name) : ContainerResource(name)
{
}

public static class TikaContainerBuilderExtensions
{
    public static IResourceBuilder<TikaContainer> AddApacheTika(this IDistributedApplicationBuilder builder, string name)
    {
        var container = new TikaContainer(name);

        return builder.AddResource(container)
            .WithImage("apache/tika", tag: "3.0.0.0")
            .WithImageRegistry("docker.io")
            .WithHttpEndpoint(port: 9998, targetPort: 9998)
            .WithHttpHealthCheck("/version");
    }
}

Usage example

// app-host
var tika = builder.AddApacheTika("apache-tika");

// service config
builder.Services.AddHttpClient<TikaClient>(options => options.BaseAddress = new Uri("http://apache-tika"));

// the-client
public class TikaClient(HttpClient httpClient)
{
    public async Task<string> GetFileContent(byte[] fileContent)
    {
        var request = new HttpRequestMessage(HttpMethod.Put, "/tika")
        {
            Content = new ByteArrayContent(fileContent),
            Headers =
            {
                Accept =
                {
                    new MediaTypeWithQualityHeaderValue("text/plain")
                }
            }
        };
        var response = await _httpClient.SendAsync(request);
        if (response.IsSuccessStatusCode)
        {
            return await response.Content.ReadAsStringAsync();
        }
        else
        {
            throw new Exception($"Failed to get file content. Status code: {response.StatusCode}");
        }
    }
}

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

@aaronpowell aaronpowell added good first issue Good for newcomers help wanted Extra attention is needed integration A new .NET Aspire integration awaiting response Waiting for the author of the issue to provide more information or answer a question labels Mar 17, 2025
Copy link
Contributor

github-actions bot commented Apr 8, 2025

We have noticed this issue has not been updated within 21 days. If there is no action on this issue in the next 14 days, we will automatically close it. You can use /stale-extend to extend the window.

@github-actions github-actions bot added the Stale label Apr 8, 2025
@Meir017
Copy link
Author

Meir017 commented Apr 8, 2025

/stale-extend

@github-actions github-actions bot removed the Stale label Apr 8, 2025
@Meir017
Copy link
Author

Meir017 commented Jun 1, 2025

Would you accept a pull request for this?

@aaronpowell
Copy link
Member

Sure would @Meir017

@Meir017 Meir017 linked a pull request Jun 6, 2025 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Waiting for the author of the issue to provide more information or answer a question good first issue Good for newcomers help wanted Extra attention is needed integration A new .NET Aspire integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants