1

When i try to run this code:

FileUtils.copyInputStreamToFile(file.getContent(), new File("upload/" + file.getName()));

I get this error:

error: cannot find symbol
symbol:   method getName()
location: variable file of type UploadedFile

I have already imported these:

import java.io.*;
import org.apache.commons.io.FileUtils;

I'm working with Gradle and I have already added to the dependencies in build.gradle.kts this one:

 implementation(group= "commons-io", name= "commons-io", version= "2.5")

so the build.gradle.kts file builds correctly.

What else should I import? What am I missing?

andrewJames
  • 19,570
  • 8
  • 19
  • 51
ALU
  • 353
  • 2
  • 4
  • 18

1 Answers1

0

Javalin's UploadedFile has no property named name. However, it has filename, so this may work (not tested):

FileUtils.copyInputStreamToFile(file.getContent(), new File("upload/" + file.getFilename()));
thokuest
  • 5,800
  • 24
  • 36