Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [rest-dev] [External] : Re: MultiPart Problems
  • From: Jan Supol <jan.supol@xxxxxxxxxx>
  • Date: Wed, 30 Aug 2023 12:10:49 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AOMzsirVKRR1MueR7MKxJtcbeGiY14nu4p2LbTdn86g=; b=Pas9i0dk8AoiAjDODam1k2y+Bx/usEopFFgMARVKgONW6CGjbGc8YP58Dx7jL9ODrLqFO4zTxoqil8qOQU4Tekk1/3xHmLHvEOZZ0eY7Lrt77f2THbipeL3o2Bs8c2VHMz+ZEYdOWqmFx1aITgPLF5pMhwMXHQBq4B/blSvOfTa1JpAEZpUda1Yg4iRJYHBD4SqMOO7vetTSk76VENT74dqdmUHJIAWL7z/9bsPU8W3pygDA2FWHJfPtTKTqdcv5+HAFMjZ2hHHZqiFvGErAIMeP1Q7O1QEhFoqzFad0E8aZouJ7BWwhfK7D1MBzcNagMiLftSrRt7AGLIDr1j8mWw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QunOf7Xz1m4PhAePgB17JC1k30QhaJuOjiqxVzUYz7noVeQ78gVgqu9VYJyqV7y0hFmhIzKpaPPLewxk57nF2H9Ub+cEBIws2KLSUUEo03Dj1tmDCIW8W+8gVQzINfIpzCcip/3oq9MuXuTMVlIeDwbTK9l0tsox/tt8ww3y+YiiPeUowGnijCzix15adHPAYQ9xssONPWY0q/dbCysEn4BtM4HxHKEpKJjE0jbIudTmKb/TPS4x8f3gn423B7I6x7gu76uH+Ycxq1qockYCqC/zqISuDlNNp2aWMGK6aqsn93fUWqE6R7qHfbi4Naf9eq9f5f+JR3IouEIDWaKUuA==
  • Delivered-to: rest-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/rest-dev/>
  • List-help: <mailto:rest-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/rest-dev>, <mailto:rest-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/rest-dev>, <mailto:rest-dev-request@eclipse.org?subject=unsubscribe>
  • Msip_labels:
  • Thread-index: AQHZ1hFoR47YsABY+k6pJmRvFVwT2rACyLZL
  • Thread-topic: [External] : Re: [rest-dev] MultiPart Problems

Hi,
Please see the Jersey example of SeBootStrap and Multipart/EntityPart feature [1].
Thanks,
Jan


From: rest-dev <rest-dev-bounces@xxxxxxxxxxx> on behalf of James Perkins via rest-dev <rest-dev@xxxxxxxxxxx>
Sent: Thursday, August 24, 2023 12:29 AM
To: Jakarta Rest project developer discussions <rest-dev@xxxxxxxxxxx>
Cc: James Perkins <jperkins@xxxxxxxxxx>
Subject: [External] : Re: [rest-dev] MultiPart Problems
 
Hello,
I can only speak from the RESTEasy perspective, but there are a few things needed to get RESTEasy working with an example like this. I did find some bugs as well, so hopefully we can get those resolved soon and make the process a bit easier :)

I created a standalone example here [1]. The main three points are:
  1. You need to include the org.jboss.resteasy:resteasy-multipart-provider. Note in WildFly you DO NOT need to do this.
  2. For now until [2] is resolved you need to add jakarta.servlet.annotation.MultipartConfig to the application.
  3. In a CDI container, again until [2] is fixed, you'd need to @Veto your application.
I will work on an example in WildFly as well. If you've got any further questions, please let me know.


On Wed, Aug 23, 2023 at 12:35 PM omniprof--- via rest-dev <rest-dev@xxxxxxxxxxx> wrote:

Hi everyone,

 

I am developing a workshop for the Eclipse Foundation on Jakarta 10 REST 3.1 services. The workshop is divided into 8 modules. There is one module I cannot get my code to work and that is using MultiPart to either upload or download an image file.

 

It should be straightforward. I have modules that take advantage of the automatic conversion from an object to a JSON serialized version of the object and vice versa. I show both SeBootstrap and server-based REST services and REST clients. I even show code using either Jersey or RESTEasy.

 

Things have fallen apart when it comes to MultiPart. Let us begin with where I am stuck. Many have written about MultiPart, but I have yet to find any working examples. There are articles that show how to code the rest service end point and articles on how to write clients. What I have not found is an article or text that presents both the service endpoint and a matching client for MultiPart. Here is an example of what I mean from the official Eclipse documentation:

https://jakarta.ee/specifications/restful-ws/3.1/jakarta-restful-ws-spec-3.1.html#consuming_multipart_formdata

 

In the text is this code fragment:

 

@Path("widgets4")

public class WidgetsResource4 {

 

    @POST

    @Consumes(MediaType.MULTIPART_FORM_DATA)

    public Response postWidget(@FormParam("part1Name") String part1,

                               @FormParam("part2Name") InputStream part2,

                               @FormParam("part3Name") EntityPart part3) {...}

}

 

There is no example how you might call this service. If I place this code in an SeBootstrap service and have it return Response.ok().build() I get:

 

WARNING: No injection source found for a parameter of type public jakarta.ws.rs.core.Response com.eclipse.restsebootstrap.FileUploadService.postWidget(java.lang.String,java.io.InputStream,jakarta.ws.rs.core.EntityPart) at index 2.

WARNING: No injection source found for a parameter of type public jakarta.ws.rs.core.Response com.eclipse.restsebootstrap.FileUploadService.uploadFile(java.lang.String,jakarta.ws.rs.core.EntityPart) at index 1.

 

I do not get any warnings when deployed as part of a server-based endpoint, but it just won’t work, throwing exceptions due to a null EntityPart. While they may be just warnings for a specific POST service, any other services that would normally run, fail as well. Remove this POST service and the remaining services work.

 

I suspect that there is a library I am missing in my dependencies. I discovered just yesterday that there are two Response classes, one for Servlets & family and one for web services. Rarely do online examples discuss dependencies. When there is code to download from a Git repo it is usually part of a project where numerous demos all use the same pom file with an overwhelming number of dependencies and plugins. Every example I am developing has its own repo.

 

All I am begging/pleading/asking for is a simple example of uploading and downloading binary files in a web service. While it should not make a difference, I work on Windows.

 

Ken Fogel

Java Champion

JChampions Conference Organizer

JCP Executive Committee Member

Research Scholar in Residence, Dawson College

Author of Transitioning to Java

All around nice guy, usually.

 

_______________________________________________
rest-dev mailing list
rest-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://accounts.eclipse.org


--
James R. Perkins
JBoss by Red Hat

Back to the top