[Pharo-users] Downloading large files with a progress bar
Sven Van Caekenberghe
sven at stfx.eu
Thu May 12 18:24:59 EDT 2016
The actual implementation of #saveContentsToFile: can be found in ZnHttpSaveContentsToFile>>#performOperation where you can see how ZnClient is invoked. Just copy that with signalProgress: true added and you should be good.
Alternatively, you could wrap the first expression as follows:
during: [ myUrl asUrl saveContentsToFile: file ]
ZnSignalProgress is a DynamicVariable that is used by ZnClient to figure out if progress should be signalled. It takes precedence over the option #signalProgress. See #withProgressDo: if you are interested.
> On 13 May 2016, at 00:14, Offray Vladimir Luna Cárdenas <offray.luna at mutabit.com> wrote:
> I'm using
> myUrl asUrl saveContentsToFile: file
> to download large files and is working fine. But I would like to add a progress bar to show the progress to the user. Previously I used
> [: bar |
> bar title: aString.
> "A classical ZnClient download with signalProgress: true;"
> on: HTTPProgress
> do: [ :progress |
> progress isEmpty ifFalse: [ bar current: progress percentage ].
> progress resume ].
> ] asJob run.
> but I don't know how to signal progress with "saveContentsToFile".
> Any hints?
More information about the Pharo-users