diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-15 18:40:24 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-15 18:40:24 +0100 |
commit | 02988fdc0bdd345bddf89171d258822cab4229d6 (patch) | |
tree | 7c8fb4385e9175bc8701588bd9bf1a71c68a3d2c /server/helpers/requests.ts | |
parent | e33b53abb397fd4d3e7e94829f2099601f03657c (diff) | |
download | PeerTube-02988fdc0bdd345bddf89171d258822cab4229d6.tar.gz PeerTube-02988fdc0bdd345bddf89171d258822cab4229d6.tar.zst PeerTube-02988fdc0bdd345bddf89171d258822cab4229d6.zip |
Fix remote image fetching
Diffstat (limited to 'server/helpers/requests.ts')
-rw-r--r-- | server/helpers/requests.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index eb8a12868..64e3ce663 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts | |||
@@ -17,11 +17,13 @@ function doRequest ( | |||
17 | } | 17 | } |
18 | 18 | ||
19 | function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) { | 19 | function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) { |
20 | return new Bluebird<request.RequestResponse>((res, rej) => { | 20 | return new Bluebird<void>((res, rej) => { |
21 | const file = createWriteStream(destPath) | ||
22 | file.on('finish', () => res()) | ||
23 | |||
21 | request(requestOptions) | 24 | request(requestOptions) |
22 | .on('response', response => res(response as request.RequestResponse)) | ||
23 | .on('error', err => rej(err)) | 25 | .on('error', err => rej(err)) |
24 | .pipe(createWriteStream(destPath)) | 26 | .pipe(file) |
25 | }) | 27 | }) |
26 | } | 28 | } |
27 | 29 | ||