Why If I upload a picture Spring Boot searches in my computer?

user14977859

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="[email protected]=G8Yua" id="[email protected]=G8Yua"> <label
                        class="custom-file-label" for="[email protected]=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 = "[email protected]=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!

k-wasilewski

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.

edited at
0

Comments

0 comments
Login to comment

Related