I'm trying to create a fil as follows from a URL (my DropBox account), then add it as an attachment to a MimeMessageHelper, but I get a FileNotFoundException
. What could I be doing wrong?
String[] attachments = {"https://dl.dropboxusercontent.com/s/XXXX/my%20Letter.docx"};
for (String attachment : attachments) {
FileSystemResource file = new FileSystemResource("url:" + attachment);
message.addAttachment(file.getFilename(), file);
}
Error:
Caused by: org.springframework.mail.MailSendException: Failed messages: javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.FileNotFoundException: url:https:\dl.dropboxusercontent.com\s\XXXX\my%20Letter.docx (The filename, directory name, or volume label syntax is incorrect); message exceptions (1) are:
Failed message 1: javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.FileNotFoundException: url:https:\dl.dropboxusercontent.com\s\XXXX\my%20Letter.docx (The filename, directory name, or volume label syntax is incorrect)
UPDATE:
How can I go about creating a FileSystemResource
from a Http URL?