Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Error 2032 in URLStream

Guest
Feb 12, 2013 Feb 12, 2013

I have an Air application that needs to loop through thousands of URLs to download and save images to the user's local drive.  I am able to get through a few hundred but receive the following error:

Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.

Others have mentioned that this error means that the URL doesn't exist or is invalid but I can guarantee that the URLs are valid.

Here is how my class is getting called:

    var fp:FileProcessor = new FileProcessor(imgPath, dirPath);

    fp.addEventListener(Event.COMPLETE, imgDownloadComplete);

    fp.startDownload();

And in imgDownloadComplete, after updating the progress bar I am calling:

  var fp:FileProcessor = event.currentTarget as FileProcessor;

  fp.removeEventListener(Event.COMPLETE, imgDownloadComplete);

  fp = null;

Finally, FileProcessor looks like:

public class FileProcessor extends EventDispatcher {

                    private var urlPath:String;

                    private var dirPath:String;

                    private var urlStream:URLStream;

                    private var fData:ByteArray;

                    private var file:File;

                    public function FileProcessor(url:String, path:String) {

                              this.urlPath = url;

                              this.dirPath = path;

             //////This next line is where the error above points to

             urlStream = new URLStream;

             urlStream.addEventListener(ProgressEvent.PROGRESS, onProgress);

             urlStream.addEventListener(Event.COMPLETE, onComplete);

                    }

                    public function startDownload():void {

                              fData = new ByteArray;

                              urlStream.load( new URLRequest(this.urlPath) );

                    }

                    private function onProgress(event:ProgressEvent):void {

                              if(urlStream.bytesAvailable == 0) return;

                              if(urlStream.connected) urlStream.readBytes(fData, fData.length);

                    }

                    private function onComplete(event:Event):void {

                              if(urlStream.connected)

                                        urlStream.close();

                              var fileStream:FileStream = new FileStream;

                              file = File.desktopDirectory.resolvePath(this.dirPath);

                              fileStream.open(file, file.exists ? FileMode.APPEND:FileMode.WRITE);

                              fileStream.writeBytes(fData);

                              fileStream.close();

                              fData.clear();

                              fData = null;

                              file = null;

                              fileStream = null;

                              urlStream.removeEventListener(ProgressEvent.PROGRESS, onProgress);

                              urlStream.removeEventListener(Event.COMPLETE, onComplete);

                              urlStream = null;

                              dispatchEvent(new Event(Event.COMPLETE));

                    }  

                    private function dispatchComplete():void {

                              dispatchEvent(new Event(Event.COMPLETE));

                    }

          }

}

ANY help or pointers that somebody can give would be greatly appreciated.  This is my first shot at an Air/Flex application so I am unsure where to look.  My company wouldn't purchase the Professional FlexBuilder so I do not have access to the profiler.

TOPICS
ActionScript
3.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 12, 2013 Feb 12, 2013

You have an incorrect path and/or file name. 

First, double check your spelling and your paths.  Then make sure your load target's path is relative to the location of your swf's embedding html file's location, if you are testing by opening the html in a browser.  If you are testing in the Flash IDE or testing by opening the swf directly, the path should be relative to the swf.

case counts when testing server file loads.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 12, 2013 Feb 12, 2013

I appreciate your response, thank you.  But, can you spell this out a bit more for me? 

The imgPath variable is the full URL to the image on the server (http://media.itemmaster.com/0/0/0/38/16196c49-fd27-489a-97f8-13d513451e10.tga) and the dirPath is the path that the user has previously choosen (

browseForDirectory) to save the image to.

I am not sure what you mean by the target's path being relative to the location of the swf.

A specific error message I am now receiving is:

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://media.itemmaster.com:80/0/0/0/506/30c8c9fb-7935-4d32-b800-444448095d1f.tif" errorID=2032]

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 12, 2013 Feb 12, 2013
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 12, 2013 Feb 12, 2013

Sure there is. It's a 3.1MB file that took me ~3.5 seconds to download.

If you are using IE, it doesn't support TIFF images, though.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 12, 2013 Feb 12, 2013

attach a screenshot showing your browser's address bar and the image.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 12, 2013 Feb 12, 2013

It doesn't display in the browser but you can see the image downloaded in the lower left.

Screen Shot 2013-02-12 at 7.58.05 PM.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 12, 2013 Feb 12, 2013

that's not the image i see. i'm seeing a peanutbutter jar.

anyway, there's probably a cross-domain issue because of something you're trying to do with that image (like access the loader's content bitmapdata property).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 13, 2013 Feb 13, 2013

I hadn't thought about the crossdomain piece. Thanks. I've verified that

my application doesn't have a memory leak it just seems to stop and hang

after a few hundred images (memory is still fairly stable)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Feb 13, 2013 Feb 13, 2013

I always use an URLchecker like this one , to check if the URL even exists or if I have the rights to access it. Maybe you should try it some time, too?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 13, 2013 Feb 13, 2013

So, I put the crossdomain.xml out there and that didn't seem to help. I

still get through a couple hundred images and the application stops.

One thing I did notice (after adding more trace statements) is that right

in the beginning I get a trace statement for each and every image (in this

case, 4782 of them) in the class that is creating the URLStream. Could

this be overloading the application?

So, I loop through all of the URLs that I need to download, creating an

instance of my FileProcessor.as class for each URL. The constructor of

FileProcessor creates a URLStream and adds listeners to the stream. for

ProgressEvent.PROGRESS and Event.COMPLETE.

Do I need to somehow throttle this so that I do not create almost 5000

calls at once?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Feb 13, 2013 Feb 13, 2013
LATEST

The event.complete listener might be not enough in your case.You have to track the Bytesizes of the data that you`re downloading. Here is a technique described that helps you to maintain a buffer that keeps the stream alive at all times. Maybe its worth a shot?

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