Skip to content
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

quarkus.http.body.uploads-directory is ignored when storing binary of REST request input #18113

Open
iompo opened this issue Jun 23, 2021 · 14 comments
Labels
area/resteasy-classic kind/bug Something isn't working

Comments

@iompo
Copy link

iompo commented Jun 23, 2021

I have a REST endpoint that receives a multipart containing a file. I tried to define a custom temporary folder where to store that file, using the property quarkus.http.body-handler.uploads-directory. When the server receives the rest request the file contained in the multipart is stored in the file system temp folder and not in the one specified by the property.
This is my REST endpoint:

    @POST
    @Consumes(MULTIPART_FORM_DATA)
    public String uploadFile(@MultipartForm BinaryRequestBody binary) throws IOException {
    ....
    }

the multipart BinaryRequestBody:

public class BinaryRequestBody {

    @FormParam("file")
    @PartType(APPLICATION_OCTET_STREAM)
    public File file;

    @FormParam("fileName")
    @PartType(TEXT_PLAIN)
    public String fileName;
}

and the application.properties:

quarkus.http.body.handle-file-uploads = true
quarkus.http.body-handler.uploads-directory = /home/tempFolder
quarkus.http.body.preallocate-body-buffer = true
quarkus.http.body.delete-uploaded-files-on-end = false

Expected behavior

The file contained in the BinaryRequestBody object should be stored into /home/tempFolder

Actual behavior

The file contained in the BinaryRequestBody is stored in the default temp directory

Quarkus version or git rev

1.13.7.Final

Build tool

Gradle 6.8.3
Kotlin: 1.4.20
Groovy: 2.5.12
JVM: 11.0.10 (AdoptOpenJDK 11.0.10+9)
OS: Mac OS X 10.16 x86_64

@iompo iompo added the kind/bug Something isn't working label Jun 23, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 23, 2021

/cc @evanchooly

@geoand
Copy link
Contributor

geoand commented Jun 23, 2021

Thanks for reporting!

Can you please share a reproducer project?

@geoand geoand added triage/needs-reproducer We are waiting for a reproducer. and removed area/kotlin labels Jun 23, 2021
@iompo
Copy link
Author

iompo commented Jun 24, 2021

Hi geoand,
here the link to a reproducer project.

@geoand
Copy link
Contributor

geoand commented Jun 24, 2021

Thanks.

It appears that RESTEasy Classic does not write the content of the multipart request to the file system, but leaves that task to the user. Is that correct @ronsigal ?

@belkevglaz
Copy link

Have the same problem. How to get this work ?

@geoand
Copy link
Contributor

geoand commented Jul 6, 2021

It doesn't work at the moment

@geoand
Copy link
Contributor

geoand commented Jan 27, 2023

cc @jamezp

@jamezp
Copy link
Contributor

jamezp commented Jan 27, 2023

I assume the goal here is to write data to a file. Currently RESTEasy uses Apache mime4j to process multipart data. It uses a ThresholdStorageProvider which stores data in memory if it's small enough, defaults to 1024 bytes. If that is surpassed then the data will be written to a file. However, it does look like there currently isn't a way to define where the temporary file is created. Is this what we're after here?

@geoand
Copy link
Contributor

geoand commented Jan 27, 2023

Exactly

@jamezp
Copy link
Contributor

jamezp commented Jan 27, 2023

Okay. We've got some changes coming up along these lines. We could add this too. However, the 4.7.x branch really isn't getting more features. We could consider it for 5.x, but RESTEasy has moved past Jakarta REST 2.1 to Jakarta REST 3.1 and eventually 4.0.

@geoand
Copy link
Contributor

geoand commented Jan 27, 2023

Understood, thanks

@geoand
Copy link
Contributor

geoand commented Sep 20, 2024

Has this perhaps been fixed with the latest versions of RESTEasy?

@geoand geoand added the triage/needs-feedback We are waiting for feedback. label Sep 20, 2024
@jamezp
Copy link
Contributor

jamezp commented Sep 23, 2024

@geoand I apologize it looks like this never got looked at. I've filed https://issues.redhat.com/browse/RESTEASY-3542 for this. Currently everything just uses the java.io.tmpdir.

@geoand
Copy link
Contributor

geoand commented Sep 23, 2024

🙏🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/resteasy-classic kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants