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
RestClient: Uploading Excel Files created with Apache POI #212
Comments
You can upload a file (any binary data) using a regular REST endpoint, for example, https://javatutorial.net/java-file-upload-rest-service. MicroProfile Rest client has nothing to do with defining REST endpoints but calling them. The Quarkus repository/Forum would be a better place to ask this question. |
I think you misunderstood my question: I want to upload a file from the java service to another service, not upload a file to the java service |
It is likely possible if you were to use a custom MessageBodyWriter to convert the File object (or whatever the parameter is) to the message body output stream. This is probably the only portable solution as most vendors have their own unique multipart implementation. I agree that this would be a good feature to have in the MP Rest Client spec. In general, we try to "piggy-back" off of JAX-RS (now Jakarta REST) for consistency. JAX-RS also does not have a spec-defined multipart API, but that has been proposed for the next release. Ideally, whatever we do in MP Rest Client would be compatible with JAX-RS. |
While it would be nice to have an implementation-neutral way of doing this as part of the spec, the current release of Quarkus, 1.7.0.Final, with a dependency on resteasy-client 4.5.6.Final, handles this just fine for me in the case of passing binary file data over to SharePoint via its REST API. Using an package com.example.sharepoint.rest;
import java.io.InputStream;
import javax.ws.rs.Consumes;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
@RegisterRestClient(configKey = "sharepoint-api")
public interface MicroprofileRestClient {
@POST
@Path("/web/GetFolderByServerRelativeUrl('{serverRelativeUrl}')/Files/add(url='{fileName}',overwrite=true)")
@Produces("application/json;odata=verbose")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
Response store(@HeaderParam("Authorization") String authorization,
@PathParam("serverRelativeUrl") String serverRelativeUrl, @PathParam("fileName") String fileName,
InputStream content);
} |
This should be solved in 3.1 with the upgrade to Jakarta REST 3.1. There was a |
similar situation to #261 |
Hello,
At our company we need to upload an excel file created using Apache POI.
I didn't find any possibility to do this.
I already tried using MultipartForm and the Workbook itself, both didn't work.
Used implementation of Rest Client: REST Easy integrated to Quarkus
Is it even possible to upload any files using the REST client? Didn't find any examples on google / stack overflow / github. If it is not possible: This is a feature request.
The text was updated successfully, but these errors were encountered: