File upload along with other object in Jersey restful web service

后端 未结 6 1781
忘掉有多难
忘掉有多难 2020-11-22 13:34

I want to create an employee information in the system by uploading an image along with employee data. I am able to do it with different rest calls using jersey. But I want

6条回答
  •  Happy的楠姐
    2020-11-22 14:02

    Your ApplicationConfig should register the MultiPartFeature.class from the glassfish.jersey.media.. so as to enable file upload

    @javax.ws.rs.ApplicationPath(ResourcePath.API_ROOT)
    public class ApplicationConfig extends ResourceConfig {  
    public ApplicationConfig() {
            //register the necessary headers files needed from client
            register(CORSConfigurationFilter.class);
            //The jackson feature and provider is used for object serialization
            //between client and server objects in to a json
            register(JacksonFeature.class);
            register(JacksonProvider.class);
            //Glassfish multipart file uploader feature
            register(MultiPartFeature.class);
            //inject and registered all resources class using the package
            //not to be tempered with
            packages("com.flexisaf.safhrms.client.resources");
            register(RESTRequestFilter.class);
        }
    

提交回复
热议问题