3 Replies - 8430 Views - Last Post: 24 March 2016 - 11:47 AM

#1 nipnuk   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-February 10

downloading a file from server in flex

Posted 08 February 2010 - 06:16 AM

I am facing problem in downloading a file from tomcat server by flex app. I have J2EE project in eclipse with tomcat 6.0. Flex is the front-end. My J2EE project is "acA4", and i copied the file "abc.rar" that i want to download in WEB-INF as well as Web-Content folders (its not clear to me where should my to be downloaded files reside??). In my flex code i have a urlrequest object with url "http://localhost:8055/acA4/abc.rar". It doesn't download the file.
Here's the source...
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="init();" viewSourceURL="srcview/index.html">
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.collections.ArrayCollection;
			import flash.net.FileReference;

			private const FILE_URL:String = "http://localhost:8055/acA4/abc.rar";
			[Bindable]

			public  var fileRef:FileReference=new FileReference();
			private var urlReq:URLRequest;
			
			private function init():void {
				urlReq = new URLRequest(FILE_URL);
				fileRef.addEventListener(Event.CANCEL, doEvent);
				fileRef.addEventListener(Event.COMPLETE, doEvent);
				fileRef.addEventListener(Event.OPEN, doEvent);
				fileRef.addEventListener(Event.SELECT, doEvent);
				fileRef.addEventListener(HTTPStatusEvent.HTTP_STATUS, doEvent);
				fileRef.addEventListener(IOErrorEvent.IO_ERROR, doEvent);
				fileRef.addEventListener(ProgressEvent.PROGRESS, doEvent);
				fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR, doEvent);
			}
			private function doEvent(evt:Event):void{
				Alert.show(evt.toString());
			}
			private function downloadSourceCodeZip():void {
				
				fileRef.download(urlReq);
				var succeed:Function = function(){};
			}
		]]>
	</mx:Script>
	
	<mx:Button id="downloadBtn" label="Download example source code" click="downloadSourceCodeZip()" toolTip="{FILE_URL}" height="40" />
	</mx:Application>



Gives this error:
[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2038"]

I googled the error , found a solution to add a function, "succeed" one still it doesn't work.

I am trying since 3 hrs but with no results..
Any body has a solution???

This post has been edited by nipnuk: 08 February 2010 - 06:29 AM


Is This A Good Question/Topic? 0
  • +

Replies To: downloading a file from server in flex

#2 Guest_nipnuk*


Reputation:

Re: downloading a file from server in flex

Posted 08 February 2010 - 08:45 AM

hey it did work!
the problem was with the placement of the file, nothin else.
Sorry 4 wasting time of those who viewed this.
Was This Post Helpful? 0

#3 ugopi15   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 24-March 16

Re: downloading a file from server in flex

Posted 24 March 2016 - 11:27 AM

Hi nipnuk,
Can you tell me where exactly did you put the file? I am running into same issue & i am using your example. Also, i have one more question. I have a file system location on server where the file resides. How do i create the FILE_URL? Or is there another way to retrieve this?

View Postnipnuk, on 08 February 2010 - 08:45 AM, said:

hey it did work!
the problem was with the placement of the file, nothin else.
Sorry 4 wasting time of those who viewed this.

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15160
  • View blog
  • Posts: 60,694
  • Joined: 12-June 08

Re: downloading a file from server in flex

Posted 24 March 2016 - 11:47 AM

Dude.. that user hasn't been on since 2010.. when s/he wrote that question. Please be cognizant of that last post date and avoid necroposting. Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1