I am building a spring boot application in which, at a certain point, the user has to input a file (image, text or whatever he wants) and this file is eventually going to be auto-sent to me by mail. I have used this, in my HTML template, to ask for the output;
<div class="custom-file">
<input type="file" class="custom-file-input"
name="6?-BBtn9E@=G8Yua" id="6?-BBtn9E@=G8Yua"> <label
class="custom-file-label" for="6?-BBtn9E@=G8Yua">Select file</label>
</div>
As you can see I'm using bootstrap.
In my spring boot controller I'm getting that param this way;
@RequestParam(name = "6?-BBtn9E@=G8Yua", required = false) File userFile
Then the mail is going to be sent regularly (I've previously tested the mail-sending worked, when I still hadn't this file input issue), hence I'm just going to show you the attaching;
HtmlEmail email = new HtmlEmail();
email.attach(userFile);
email.send();
However, when I submit, I get this IOException in the console;
java.io.IOException: "/Users/username/Eclipse-Workspace/Website/file.txt" does not exist
I've picked up a file called file.txt, and since I'm running this on a mac computer the path is /Users/{myUsername}/{Eclipse-Workspace}/{Spring-Boot-Project/{file-name}. What I want is that Spring Boot searches out of the project, not just inside of it.
Why is it doing so? Thanks for reading!
When you want Spring to look outside the project folder you want: "file:/Users/username/Eclipse-Workspace/Website/file.txt"
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments