문제

This really is two questions in one since they are both faces of the same coin :) ...

1) How can I upload a file to a servlet from an application/service, in other words without a html form that a user should fill in?

2) On the receiving end, I have used Apache FileUpload before, but this handles form inputs, is there another way to handle an upload not coming from a form?

Thank you for your help

Jonny

도움이 되었습니까?

해결책

1) How can I upload a file to a servlet from an application/service, in other words without a html form that a user should fill in?

You have to create a HTTP request containing the correct headers (multipart/formdata) that contains the file you want to upload. Have a look at this post: Upload files from Java client to a HTTP server. I haven't tried it, but it looks as if it could work.

2) On the receiving end, I have used Apache FileUpload before, but this handles form inputs, is there another way to handle an upload not coming from a form?

You should still be able to use Apache FileUpload on the receiving end since it merely parses the HTTP request which should still be formatted in the same way.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top