Non blocking downloads utility (see how they can be used in the Comtrade package).
This commit is contained in:
parent
dadc950987
commit
76ee21f9a3
@ -11,7 +11,7 @@ Class {
|
|||||||
{ #category : #'graphical interface' }
|
{ #category : #'graphical interface' }
|
||||||
GrafoscopioUtils class >> downloadingFrom: downloadUrl withMessage: aString into: location [
|
GrafoscopioUtils class >> downloadingFrom: downloadUrl withMessage: aString into: location [
|
||||||
| fileName |
|
| fileName |
|
||||||
fileName := downloadUrl segments last.
|
fileName := (self sanitize: downloadUrl) segments last.
|
||||||
(location / fileName) ensureDelete.
|
(location / fileName) ensureDelete.
|
||||||
[: bar |
|
[: bar |
|
||||||
bar title: aString.
|
bar title: aString.
|
||||||
@ -28,6 +28,24 @@ GrafoscopioUtils class >> downloadingFrom: downloadUrl withMessage: aString into
|
|||||||
] asJob run.
|
] asJob run.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'graphical interface' }
|
||||||
|
GrafoscopioUtils class >> getContentsFrom: url withMessage: aString [
|
||||||
|
| client |
|
||||||
|
[: bar |
|
||||||
|
bar title: aString.
|
||||||
|
[client := ZnClient new
|
||||||
|
enforceHttpSuccess: true;
|
||||||
|
get: (url);
|
||||||
|
signalProgress: true
|
||||||
|
]
|
||||||
|
on: HTTPProgress
|
||||||
|
do: [ :progress |
|
||||||
|
progress isEmpty ifFalse: [ bar current: progress percentage ].
|
||||||
|
progress resume ].
|
||||||
|
] asJob run.
|
||||||
|
^ client contents.
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #private }
|
{ #category : #private }
|
||||||
GrafoscopioUtils class >> sanitize: url [
|
GrafoscopioUtils class >> sanitize: url [
|
||||||
"I remove white spaces in url's and prepend 'http://' to urls when it is ommited, so
|
"I remove white spaces in url's and prepend 'http://' to urls when it is ommited, so
|
||||||
|
Loading…
Reference in New Issue
Block a user