Fix problem if content-type isn't provided by server
All checks were successful
CI / CI (push) Successful in 1m22s
All checks were successful
CI / CI (push) Successful in 1m22s
This commit is contained in:
parent
8570b2a204
commit
6a0350f13c
1 changed files with 2 additions and 1 deletions
|
@ -97,7 +97,8 @@ module.exports = {
|
|||
return {value: 3, errorMessage: error.cause.message};
|
||||
}
|
||||
if(!res.ok) return {value: 1, errorMessage: res.status.toString()};
|
||||
if(!res.headers.get('content-type').startsWith("image")) return {value: 2, errorMessage: ""};
|
||||
const contentType = res.headers.get('content-type');
|
||||
if(!contentType || !contentType.startsWith("image")) return {value: 2, errorMessage: contentType || "No content-type header"};
|
||||
const stream = Readable.fromWeb(res.body)
|
||||
await writeFile(path, stream);
|
||||
return {value: 0, errorMessage: ""};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue