0

I use fileReference.download() to download files. The fileReference send request to java servlet.In servlet, some error may be checked. For example error - 'File not found'. I want to send the error to flex side. I tried lots of methods,but fileReference in flex can't receive them. Such as

response.sendError(HttpServletResponse.SC_NOT_FOUND, "File not found");

or

PrintWriter out = resp.getWriter(); out.print("File not found");

It seems fileReference can't triggers event 'DataEvent.UPLOAD_COMPLETE_DATA' and 'HTTPStatusEvent.HTTP_STATUS'. Can somebody tell me how to get servlet error message in fileReference. Thanks

Pansy Xue
  • 25
  • 6

2 Answers2

0

Think there is no solution. I tried hard several ways like responding with 500, sendError over response with message, returning XML document (but you don't have control over downloaded content). I solved the issue by creating a "allround error message" that fits to most situation (you have no permission or content is unavailable...)

Other solution is to download with navigateTo but then you need to open a browser window.

Frank Szilinski
  • 550
  • 1
  • 5
  • 18
0

I do not believe FileReference.download dispatches a HttpStatus event, nor exposes status code.

You can only listen for IOErrorEvent.

Jason Sturges
  • 15,855
  • 14
  • 59
  • 80
  • I haved listened for IOErrorEvent. But the error message is something like '#2038'. I want to get some useful messages, such as the message I send in response.sendError(HttpServletResponse.SC_NOT_FOUND, "File not found"); – Pansy Xue Jul 20 '11 at 04:43