I have an api in quarkus java when I upload the file I can't get the original name of it. When I use File.getName the return I get is this pfx16311440985252189274sfx
`
package br.com.upload.controller;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.jboss.resteasy.annotations.providers.multipart.MultipartForm;
import br.com.upload.entity.MultipartBody;
@Path("upload")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class UploadController {
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public String sendUploada(@MultipartForm MultipartBody data) throws IOException {
InputStream is = new BufferedInputStream(new FileInputStream(data.file));
// String mimeType = URLConnection.guessContentTypeFromStream(is);
// Long size = data.file.length();
System.out.println("data file " + data.file.getName());
Files.copy(is,
new File("/home/allanfenx/Público/Java/upload/src/main/resources/upload",
"mai.png")
.toPath(),
StandardCopyOption.REPLACE_EXISTING);
return data.fileName;
}
}`
`package br.com.upload.entity;
import java.io.File;
import javax.ws.rs.FormParam;
import javax.ws.rs.core.MediaType;
import org.jboss.resteasy.annotations.providers.multipart.PartType;
public class MultipartBody {
@FormParam("file")
@PartType(MediaType.APPLICATION_OCTET_STREAM)
public File file;
@FormParam("fileName")
@PartType(MediaType.APPLICATION_JSON)
public String fileName;
}`
This is my code quarkus uses InputStream but I'm using File. The code works perfectly but I can't get the original file name. The return I have is pfx16311440985252189274sfx it looks like they are characters to be decoded