Pergunta

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

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top