Загрузить на локальный WebDav - Spring BootJAVA

Программисты JAVA общаются здесь
Anonymous
Загрузить на локальный WebDav - Spring Boot

Сообщение Anonymous »

У меня есть проблемы с файлом загрузки в локальный WebDav. Пока что у меня есть: < /p>
public interface IStorageService {
URI SaveFile(String filename, InputStream inputStream);
}
< /code>
@Component
public class LocalStorageService implements IStorageService {
@Value( "C:\temp" )
private String filestorePath;

public URI SaveFile(String filename, InputStream inputStream) {
var rootLocation = Paths.get(filestorePath);
var filePath = rootLocation.resolve(filename);
try {
Files.copy(inputStream, filePath);
} catch (IOException e) {
throw new RuntimeException("Failure save file to " + filename + " in " + filestorePath + "." + e.getMessage(), e);
}
return filePath.toUri();
}
}
< /code>
and controller
private final DocumentService documentService;

public DocumentController(DocumentService documentService) {
this.documentService = documentService;
}

@RequestMapping(method = RequestMethod.POST)
public DocumentModel handleFileUpload(@RequestParam("file") MultipartFile file) throws IOException {
return documentService.handleFileUpload(file.getOriginalFilename(), file.getInputStream());
}
< /code>
And it is works correctly, the file is uploaded to C:/temp...
Now I would like to do the same but upload file to local WebDav. When i change in @Value "C:\temp to "http://localhost" (this is ma webdav location) i have:
invalidpathexception: illegal char at index 4: http://localhost
< /code>
or when I declare http//localhost without
nosuchfileexception: http\localhost
< /code>
How can I write my code to upload file directly to WebDav.
Parameters of SaveFile method cannot be changed, I need do it with Name as String and InputStream.
I tried with Sardine but to no avail. Could someone help me, give any tips or maybe suggestion of code ?
Greetings !

Подробнее здесь: https://stackoverflow.com/questions/653 ... pring-boot

Вернуться в «JAVA»