Highlighted

File.upload on Air SDK for iOS devices failed to send http request to server.

Community Beginner ,
Mar 02, 2015

Copy link to clipboard

Copied

I am trying to use ActionScript's File.upload to upload a file on Air SDK for iOS8 environment, but the File.upload does not work properly. No handler about the file upload is executed after File.upload is invoked, and no exception is caught. When I check the network traffic of the server side, I found that no http request even hit the server after File.upload is executed. The code snippet here is very simple.

----------------------------------------------------------

  private var file:File;

  private var dir:File;

  //This method is executed to create a file and upload it when the Upload Button is pressed.

  protected function OnUploadButtonPressed(event:MouseEvent):void{

  var str:String = 'This is test';

  var imageBytes:ByteArray = new ByteArray();

  for ( var i:int = 0; i < str.length; i++ ) {

  imageBytes.writeByte( str.charCodeAt(i) );

  }

  try{

  dir = File.applicationStorageDirectory

  var now:Date = new Date();

  var filename:String = "test" + now.seconds + now.milliseconds + ".txt";

  file = dir.resolvePath( filename );

  var stream:FileStream = new FileStream();

  stream.open( file, FileMode.WRITE );

  stream.writeBytes( imageBytes );

  stream.close();

  file.addEventListener( Event.COMPLETE, uploadComplete );

  file.addEventListener( IOErrorEvent.IO_ERROR, ioError );

  file.addEventListener( SecurityErrorEvent.SECURITY_ERROR, securityError );

  file.addEventListener(ErrorEvent.ERROR, someError);

  file.addEventListener(ProgressEvent.PROGRESS, onProgress);

  file.upload( new URLRequest("http://10.60.99.31/MyPath/fileUploadTest.do"));//This line does not work. No handler is executed. No http request hit the server side.

  } catch( e:Error ) {

  trace( e );

  }

  }

  //Complete Handler

  private function uploadComplete( event:Event ):void

  {

  trace( "Upload successful." );

  }

  //IOError handler

  private function ioError( error:IOErrorEvent ):void

  {

  trace( "Upload failed: " + error.text );

  }

  //SecurityError handler

  private function securityError(error:SecurityErrorEvent):void{

  trace( "Security error:" + error.text );

  }

  //Other handler

  private function someError(error:ErrorEvent):void{

  trace("some error" + error.text);

  }

  //Progress handler

  private function onProgress(event:ProgressEvent):void{

  trace("progressHandler");

  }

------------------------------------------------------

When executed on Air Simulator, it works fine as expected, and the file is successfully uploaded to the server. But When executed on iOS devices(in my case, iPad), as I explain early, no handler about the file upload is executed, and no the http request even hit the server. So I think the problem may be in the client side. It seems that the Air SDK for iOS just failed to send the http request for some reason.


To make my problem more clear, I list my environment below:

  • Development Environment:  Windows7 (64bit)  / Mac os 10.9.4 (Tested on  OS platforms.)
  • IDE: Flash Builder 4.7
  • Air SDK:  3.8 / 16.0.0 (After I updated to the lastest Air SDK 16.0.0 , the problem still exists.)
  • Application Server:  Tomcat7 + Spring
  • Target OS: iOS 8


I have been struggling for this for days. So I really appreciate it if anyone has any idea about this.

Thanks in advance.

TOPICS
Development

Views

579

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

File.upload on Air SDK for iOS devices failed to send http request to server.

Community Beginner ,
Mar 02, 2015

Copy link to clipboard

Copied

I am trying to use ActionScript's File.upload to upload a file on Air SDK for iOS8 environment, but the File.upload does not work properly. No handler about the file upload is executed after File.upload is invoked, and no exception is caught. When I check the network traffic of the server side, I found that no http request even hit the server after File.upload is executed. The code snippet here is very simple.

----------------------------------------------------------

  private var file:File;

  private var dir:File;

  //This method is executed to create a file and upload it when the Upload Button is pressed.

  protected function OnUploadButtonPressed(event:MouseEvent):void{

  var str:String = 'This is test';

  var imageBytes:ByteArray = new ByteArray();

  for ( var i:int = 0; i < str.length; i++ ) {

  imageBytes.writeByte( str.charCodeAt(i) );

  }

  try{

  dir = File.applicationStorageDirectory

  var now:Date = new Date();

  var filename:String = "test" + now.seconds + now.milliseconds + ".txt";

  file = dir.resolvePath( filename );

  var stream:FileStream = new FileStream();

  stream.open( file, FileMode.WRITE );

  stream.writeBytes( imageBytes );

  stream.close();

  file.addEventListener( Event.COMPLETE, uploadComplete );

  file.addEventListener( IOErrorEvent.IO_ERROR, ioError );

  file.addEventListener( SecurityErrorEvent.SECURITY_ERROR, securityError );

  file.addEventListener(ErrorEvent.ERROR, someError);

  file.addEventListener(ProgressEvent.PROGRESS, onProgress);

  file.upload( new URLRequest("http://10.60.99.31/MyPath/fileUploadTest.do"));//This line does not work. No handler is executed. No http request hit the server side.

  } catch( e:Error ) {

  trace( e );

  }

  }

  //Complete Handler

  private function uploadComplete( event:Event ):void

  {

  trace( "Upload successful." );

  }

  //IOError handler

  private function ioError( error:IOErrorEvent ):void

  {

  trace( "Upload failed: " + error.text );

  }

  //SecurityError handler

  private function securityError(error:SecurityErrorEvent):void{

  trace( "Security error:" + error.text );

  }

  //Other handler

  private function someError(error:ErrorEvent):void{

  trace("some error" + error.text);

  }

  //Progress handler

  private function onProgress(event:ProgressEvent):void{

  trace("progressHandler");

  }

------------------------------------------------------

When executed on Air Simulator, it works fine as expected, and the file is successfully uploaded to the server. But When executed on iOS devices(in my case, iPad), as I explain early, no handler about the file upload is executed, and no the http request even hit the server. So I think the problem may be in the client side. It seems that the Air SDK for iOS just failed to send the http request for some reason.


To make my problem more clear, I list my environment below:

  • Development Environment:  Windows7 (64bit)  / Mac os 10.9.4 (Tested on  OS platforms.)
  • IDE: Flash Builder 4.7
  • Air SDK:  3.8 / 16.0.0 (After I updated to the lastest Air SDK 16.0.0 , the problem still exists.)
  • Application Server:  Tomcat7 + Spring
  • Target OS: iOS 8


I have been struggling for this for days. So I really appreciate it if anyone has any idea about this.

Thanks in advance.

TOPICS
Development

Views

580

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 02, 2015 0
Participant ,
Mar 16, 2015

Copy link to clipboard

Copied

It works for us on iOS.

Try setting the method of the URLRequest object to URLRequestMethod.POST - the default is to create a HTTP GET request.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 16, 2015 0
Community Beginner ,
Apr 14, 2015

Copy link to clipboard

Copied

Dear dqh360

   Thank you very much for you reply.

   In fact, I tried both POST and GET method, but it seems it is not the case. It is about the http proxy Auto configuration on iOS. Please check the following link to see the detail. Again, thank you very much.

ActionScript's File.upload does not work on Air SDK for iOS devices

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 14, 2015 0
tdwivedi LATEST
Adobe Employee ,
Apr 14, 2015

Copy link to clipboard

Copied

Hi bluewindice‌ ,

As you have quoted ( ActionScript's File.upload does not work on Air SDK for iOS devices ) , this issue has been replicated at our end, and our team will be working on it.

Thanks,

Tushar

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 14, 2015 0