質問

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