开发者

Upload a file from Flex/Flash interface to a Java server using a webservice

开发者 https://www.devze.com 2023-02-27 03:10 出处:网络
I would like to transfer a file from the Flex front end to a back end Java web service, how can I achieve this ?

I would like to transfer a file from the Flex front end to a back end Java web service, how can I achieve this ?

Will byte array be a good option for the transfer ?

It would be a开发者_Python百科ppreciated if you can give a hint as to how to achieve the solution or point me in the right direction.

Note: the file is a small .jpg file, and I am new to Java


Have a look on http://www.adobe.com/devnet/flex/articles/file_upload.html


You can use Flex "FileReference class" to Upload a file on Server

Flex Working with file upload and download

and commonly on server there should be a servlet to accept multipart request using

Apache Commons FileUpload

this is useful example of servlet

Servlet File Upload Example

Hopes that helps


I have used a byte array to transfer files when I know they will be small. It can be a lot simpler to post them when dealing with https/cert issues, etc. that FileReference does not work well with. A FileReference upload is your other option (typical solution). Either way you'll use FileReference to select the file and then either use .upload to upload it or .load to load bytes in. Then you'll use .data to get the byte array. If your Jpg is coming from a snapshot taken from a flex component in memory, you'll need to work with a special Jpeg image encoder. I can tell you how to do that if that is what you are doing. Really beyond the scope of your original question, though.

0

精彩评论

暂无评论...
验证码 换一张
取 消