File Progress event

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

File Progress event

ScottM
Hi
    i have copied this code off the flex site   https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html#event:progress <https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html#event:progress>

but the progress does not seem to fire,


    private function saveReport():void {

      cursorManager.removeBusyCursor();
      var buffer:ByteArray = myPDF.save(Method.LOCAL);
      var file:FileReference = new FileReference();
      configureListeners(file);
       file.save(buffer, "Overview Report.pdf");

   }

   private function configureListeners(dispatcher:IEventDispatcher):void {
 
      dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
 
   }


   protected function progressHandler(event:ProgressEvent):void
   {
      var file:FileReference = FileReference(event.target);
      trace("progressHandler name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
   }

Reply | Threaded
Open this post in threaded view
|

Re: File Progress event

Alex Harui-2
How big is the buffer ByteArray and where are you writing the file?  If
the write can happen fast enough, no Progress events are fired.  From the
link you posted:

"In some cases, progress events are not received. For example, when the
file being transmitted is very small or the upload or download happens
very quickly a progress event might not be dispatched."

HTH,
-Alex

On 12/10/17, 11:04 AM, "scott matheson" <[hidden email]> wrote:

>Hi
>    i have copied this code off the flex site
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fhelp.adob
>e.com%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%2F3%2Fflash%2Fnet
>%2FFileReference.html%23event%3Aprogress&data=02%7C01%7Caharui%40adobe.com
>%7C5145f08e886e42dd00ef08d54000d165%7Cfa7b1b5a7b34438794aed2c178decee1%7C0
>%7C0%7C636485294617358223&sdata=t0JXnVPLx%2BtytYlHob%2B2kjcAm4VexBH%2FYrls
>PTnyOTY%3D&reserved=0
><https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fhelp.ado
>be.com%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%2F3%2Fflash%2Fne
>t%2FFileReference.html%23event%3Aprogress&data=02%7C01%7Caharui%40adobe.co
>m%7C5145f08e886e42dd00ef08d54000d165%7Cfa7b1b5a7b34438794aed2c178decee1%7C
>0%7C0%7C636485294617358223&sdata=t0JXnVPLx%2BtytYlHob%2B2kjcAm4VexBH%2FYrl
>sPTnyOTY%3D&reserved=0>
>
>but the progress does not seem to fire,
>
>
>    private function saveReport():void {
>
>      cursorManager.removeBusyCursor();
>      var buffer:ByteArray = myPDF.save(Method.LOCAL);
>      var file:FileReference = new FileReference();
>      configureListeners(file);
>       file.save(buffer, "Overview Report.pdf");
>
>   }
>
>   private function configureListeners(dispatcher:IEventDispatcher):void {
>
>      dispatcher.addEventListener(ProgressEvent.PROGRESS,
>progressHandler);
>
>   }
>
>
>   protected function progressHandler(event:ProgressEvent):void
>   {
>      var file:FileReference = FileReference(event.target);
>      trace("progressHandler name=" + file.name + " bytesLoaded=" +
>event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
>   }
>

Reply | Threaded
Open this post in threaded view
|

Re: File Progress event

ScottM
Alex
        The buffer is the default size, the save take 1-2 mins elapsed time, thats way I wanted to add a indicator , i can spoof something if i need too

Scott



> On 11 Dec 2017, at 02:20, Alex Harui <[hidden email]> wrote:
>
> How big is the buffer ByteArray and where are you writing the file?  If
> the write can happen fast enough, no Progress events are fired.  From the
> link you posted:
>
> "In some cases, progress events are not received. For example, when the
> file being transmitted is very small or the upload or download happens
> very quickly a progress event might not be dispatched."
>
> HTH,
> -Alex
>
> On 12/10/17, 11:04 AM, "scott matheson" <[hidden email]> wrote:
>
>> Hi
>>   i have copied this code off the flex site
>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fhelp.adob
>> e.com%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%2F3%2Fflash%2Fnet
>> %2FFileReference.html%23event%3Aprogress&data=02%7C01%7Caharui%40adobe.com
>> %7C5145f08e886e42dd00ef08d54000d165%7Cfa7b1b5a7b34438794aed2c178decee1%7C0
>> %7C0%7C636485294617358223&sdata=t0JXnVPLx%2BtytYlHob%2B2kjcAm4VexBH%2FYrls
>> PTnyOTY%3D&reserved=0
>> <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fhelp.ado
>> be.com%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%2F3%2Fflash%2Fne
>> t%2FFileReference.html%23event%3Aprogress&data=02%7C01%7Caharui%40adobe.co
>> m%7C5145f08e886e42dd00ef08d54000d165%7Cfa7b1b5a7b34438794aed2c178decee1%7C
>> 0%7C0%7C636485294617358223&sdata=t0JXnVPLx%2BtytYlHob%2B2kjcAm4VexBH%2FYrl
>> sPTnyOTY%3D&reserved=0>
>>
>> but the progress does not seem to fire,
>>
>>
>>   private function saveReport():void {
>>
>>     cursorManager.removeBusyCursor();
>>     var buffer:ByteArray = myPDF.save(Method.LOCAL);
>>     var file:FileReference = new FileReference();
>>     configureListeners(file);
>>      file.save(buffer, "Overview Report.pdf");
>>
>>  }
>>
>>  private function configureListeners(dispatcher:IEventDispatcher):void {
>>
>>     dispatcher.addEventListener(ProgressEvent.PROGRESS,
>> progressHandler);
>>
>>  }
>>
>>
>>  protected function progressHandler(event:ProgressEvent):void
>>  {
>>     var file:FileReference = FileReference(event.target);
>>     trace("progressHandler name=" + file.name + " bytesLoaded=" +
>> event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
>>  }
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: File Progress event

Alex Harui-2
Hi Scott,

Are you running on Windows with anti-virus software?  See this post [1].
I've had similar experiences with Flash/AIR and File I/O.  To the runtime,
the write happens quickly, into a memory buffer, then the AV software
takes 1-2 mins to scan it before writing it.

HTH,
-Alex

[1]
https://stackoverflow.com/questions/2930513/monitoring-file-upload-progress
-in-actionscript-3

On 12/11/17, 2:51 AM, "scott matheson" <[hidden email]> wrote:

>Alex
>        The buffer is the default size, the save take 1-2 mins elapsed
>time, thats way I wanted to add a indicator , i can spoof something if i
>need too
>
>Scott
>
>
>
>> On 11 Dec 2017, at 02:20, Alex Harui <[hidden email]> wrote:
>>
>> How big is the buffer ByteArray and where are you writing the file?  If
>> the write can happen fast enough, no Progress events are fired.  From
>>the
>> link you posted:
>>
>> "In some cases, progress events are not received. For example, when the
>> file being transmitted is very small or the upload or download happens
>> very quickly a progress event might not be dispatched."
>>
>> HTH,
>> -Alex
>>
>> On 12/10/17, 11:04 AM, "scott matheson" <[hidden email]> wrote:
>>
>>> Hi
>>>   i have copied this code off the flex site
>>>
>>>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fhelp.ad
>>>ob
>>>
>>>e.com%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%2F3%2Fflash%2Fn
>>>et
>>>
>>>%2FFileReference.html%23event%3Aprogress&data=02%7C01%7Caharui%40adobe.c
>>>om
>>>
>>>%7C5145f08e886e42dd00ef08d54000d165%7Cfa7b1b5a7b34438794aed2c178decee1%7
>>>C0
>>>
>>>%7C0%7C636485294617358223&sdata=t0JXnVPLx%2BtytYlHob%2B2kjcAm4VexBH%2FYr
>>>ls
>>> PTnyOTY%3D&reserved=0
>>>
>>><https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fhelp.a
>>>do
>>>
>>>be.com%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%2F3%2Fflash%2F
>>>ne
>>>
>>>t%2FFileReference.html%23event%3Aprogress&data=02%7C01%7Caharui%40adobe.
>>>co
>>>
>>>m%7C5145f08e886e42dd00ef08d54000d165%7Cfa7b1b5a7b34438794aed2c178decee1%
>>>7C
>>>
>>>0%7C0%7C636485294617358223&sdata=t0JXnVPLx%2BtytYlHob%2B2kjcAm4VexBH%2FY
>>>rl
>>> sPTnyOTY%3D&reserved=0>
>>>
>>> but the progress does not seem to fire,
>>>
>>>
>>>   private function saveReport():void {
>>>
>>>     cursorManager.removeBusyCursor();
>>>     var buffer:ByteArray = myPDF.save(Method.LOCAL);
>>>     var file:FileReference = new FileReference();
>>>     configureListeners(file);
>>>      file.save(buffer, "Overview Report.pdf");
>>>
>>>  }
>>>
>>>  private function configureListeners(dispatcher:IEventDispatcher):void
>>>{
>>>
>>>     dispatcher.addEventListener(ProgressEvent.PROGRESS,
>>> progressHandler);
>>>
>>>  }
>>>
>>>
>>>  protected function progressHandler(event:ProgressEvent):void
>>>  {
>>>     var file:FileReference = FileReference(event.target);
>>>     trace("progressHandler name=" + file.name + " bytesLoaded=" +
>>> event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
>>>  }
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: File Progress event

Scott Matheson
No I am running on a Mac, the speed to download is proportional to the number of report pages

Sent from my iPhone

On 11 Dec 2017, at 18:34, Alex Harui <[hidden email]<mailto:[hidden email]>> wrote:

Hi Scott,

Are you running on Windows with anti-virus software?  See this post [1].
I've had similar experiences with Flash/AIR and File I/O.  To the runtime,
the write happens quickly, into a memory buffer, then the AV software
takes 1-2 mins to scan it before writing it.

HTH,
-Alex

[1]
https://stackoverflow.com/questions/2930513/monitoring-file-upload-progress
-in-actionscript-3

On 12/11/17, 2:51 AM, "scott matheson" <[hidden email]<mailto:[hidden email]>> wrote:

Alex
      The buffer is the default size, the save take 1-2 mins elapsed
time, thats way I wanted to add a indicator , i can spoof something if i
need too

Scott



On 11 Dec 2017, at 02:20, Alex Harui <[hidden email]<mailto:[hidden email]>> wrote:

How big is the buffer ByteArray and where are you writing the file?  If
the write can happen fast enough, no Progress events are fired.  From
the
link you posted:

"In some cases, progress events are not received. For example, when the
file being transmitted is very small or the upload or download happens
very quickly a progress event might not be dispatched."

HTH,
-Alex

On 12/10/17, 11:04 AM, "scott matheson" <[hidden email]<mailto:[hidden email]>> wrote:

Hi
 i have copied this code off the flex site

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fhelp.ad
ob

e.com<http://e.com>%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%2F3%2Fflash%2Fn
et

%2FFileReference.html%23event%3Aprogress&data=02%7C01%7Caharui%40adobe.c
om

%7C5145f08e886e42dd00ef08d54000d165%7Cfa7b1b5a7b34438794aed2c178decee1%7
C0

%7C0%7C636485294617358223&sdata=t0JXnVPLx%2BtytYlHob%2B2kjcAm4VexBH%2FYr
ls
PTnyOTY%3D&reserved=0

<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fhelp.a
do

be.com<http://be.com>%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%2F3%2Fflash%2F
ne

t%2FFileReference.html%23event%3Aprogress&data=02%7C01%7Caharui%40adobe.
co

m%7C5145f08e886e42dd00ef08d54000d165%7Cfa7b1b5a7b34438794aed2c178decee1%
7C

0%7C0%7C636485294617358223&sdata=t0JXnVPLx%2BtytYlHob%2B2kjcAm4VexBH%2FY
rl
sPTnyOTY%3D&reserved=0>

but the progress does not seem to fire,


 private function saveReport():void {

   cursorManager.removeBusyCursor();
   var buffer:ByteArray = myPDF.save(Method.LOCAL);
   var file:FileReference = new FileReference();
   configureListeners(file);
    file.save(buffer, "Overview Report.pdf");

}

private function configureListeners(dispatcher:IEventDispatcher):void
{

   dispatcher.addEventListener(ProgressEvent.PROGRESS,
progressHandler);

}


protected function progressHandler(event:ProgressEvent):void
{
   var file:FileReference = FileReference(event.target);
   trace("progressHandler name=" + file.name + " bytesLoaded=" +
event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
}




Reply | Threaded
Open this post in threaded view
|

Re: File Progress event

Alex Harui-2
I suppose AV software could result in a similar problem on Mac.  If you
are running AV, try disabling it.

Another thing to do is get the current time at the save() call and then
when the "complete" event comes in to see if it matches the observed time
to save.

I noticed you said "download" but aren't you using the "save" method?

HTH,
-Alex

On 12/11/17, 2:20 PM, "Scott Matheson" <[hidden email]> wrote:

>No I am running on a Mac, the speed to download is proportional to the
>number of report pages
>
>Sent from my iPhone
>
>On 11 Dec 2017, at 18:34, Alex Harui
><[hidden email]<mailto:[hidden email]>> wrote:
>
>Hi Scott,
>
>Are you running on Windows with anti-virus software?  See this post [1].
>I've had similar experiences with Flash/AIR and File I/O.  To the runtime,
>the write happens quickly, into a memory buffer, then the AV software
>takes 1-2 mins to scan it before writing it.
>
>HTH,
>-Alex
>
>[1]
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackover
>flow.com%2Fquestions%2F2930513%2Fmonitoring-file-upload-progress&data=02%7
>C01%7Caharui%40adobe.com%7C3f192183c46941f1c46008d540f926bc%7Cfa7b1b5a7b34
>438794aed2c178decee1%7C0%7C0%7C636486361227785056&sdata=dIEeZvA6mPW7Xx9QrE
>o8dQvkCcW%2FGFjCNrjfTWwhl6I%3D&reserved=0
>-in-actionscript-3
>
>On 12/11/17, 2:51 AM, "scott matheson"
><[hidden email]<mailto:[hidden email]>> wrote:
>
>Alex
>      The buffer is the default size, the save take 1-2 mins elapsed
>time, thats way I wanted to add a indicator , i can spoof something if i
>need too
>
>Scott
>
>
>
>On 11 Dec 2017, at 02:20, Alex Harui
><[hidden email]<mailto:[hidden email]>> wrote:
>
>How big is the buffer ByteArray and where are you writing the file?  If
>the write can happen fast enough, no Progress events are fired.  From
>the
>link you posted:
>
>"In some cases, progress events are not received. For example, when the
>file being transmitted is very small or the upload or download happens
>very quickly a progress event might not be dispatched."
>
>HTH,
>-Alex
>
>On 12/10/17, 11:04 AM, "scott matheson"
><[hidden email]<mailto:[hidden email]>> wrote:
>
>Hi
> i have copied this code off the flex site
>
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fhelp.ad
>ob
>
>e.com<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fe.co
>m&data=02%7C01%7Caharui%40adobe.com%7C3f192183c46941f1c46008d540f926bc%7Cf
>a7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636486361227785056&sdata=wYYaoln
>HG7oYpnU3CujIaej7n6OhvjYbA5aqzz2KSbw%3D&reserved=0>%2Fen_US%2FFlashPlatfor
>m%2Freference%2Factionscript%2F3%2Fflash%2Fn
>et
>
>%2FFileReference.html%23event%3Aprogress&data=02%7C01%7Caharui%40adobe.c
>om
>
>%7C5145f08e886e42dd00ef08d54000d165%7Cfa7b1b5a7b34438794aed2c178decee1%7
>C0
>
>%7C0%7C636485294617358223&sdata=t0JXnVPLx%2BtytYlHob%2B2kjcAm4VexBH%2FYr
>ls
>PTnyOTY%3D&reserved=0
>
><https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fhelp.a
>do
>
>be.com<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbe.
>com&data=02%7C01%7Caharui%40adobe.com%7C3f192183c46941f1c46008d540f926bc%7
>Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636486361227785056&sdata=w16Y2
>IHiOu5SqBTXFyI%2BnUf%2FMC6tspMxrzZHmiKmUSo%3D&reserved=0>%2Fen_US%2FFlashP
>latform%2Freference%2Factionscript%2F3%2Fflash%2F
>ne
>
>t%2FFileReference.html%23event%3Aprogress&data=02%7C01%7Caharui%40adobe.
>co
>
>m%7C5145f08e886e42dd00ef08d54000d165%7Cfa7b1b5a7b34438794aed2c178decee1%
>7C
>
>0%7C0%7C636485294617358223&sdata=t0JXnVPLx%2BtytYlHob%2B2kjcAm4VexBH%2FY
>rl
>sPTnyOTY%3D&reserved=0>
>
>but the progress does not seem to fire,
>
>
> private function saveReport():void {
>
>   cursorManager.removeBusyCursor();
>   var buffer:ByteArray = myPDF.save(Method.LOCAL);
>   var file:FileReference = new FileReference();
>   configureListeners(file);
>    file.save(buffer, "Overview Report.pdf");
>
>}
>
>private function configureListeners(dispatcher:IEventDispatcher):void
>{
>
>   dispatcher.addEventListener(ProgressEvent.PROGRESS,
>progressHandler);
>
>}
>
>
>protected function progressHandler(event:ProgressEvent):void
>{
>   var file:FileReference = FileReference(event.target);
>   trace("progressHandler name=" + file.name + " bytesLoaded=" +
>event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
>}
>
>
>
>