-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathimageDownload.js
35 lines (30 loc) · 1.09 KB
/
imageDownload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const lark = require("@larksuiteoapi/allcore");
const fs = require("fs")
const appSettings = lark.getInternalAppSettingsByEnv()
const conf = lark.newConfig(lark.Domain.FeiShu, appSettings, {
loggerLevel: lark.LoggerLevel.ERROR,
})
let queryParams = {
image_key: "img_v2_332fc963-94f6-4147-ba3a-c8f5f745d6fg"
}
let req = lark.api.newRequest("image/v4/get", "GET", lark.api.AccessTokenType.Tenant, undefined)
req.setQueryParams(queryParams)
req.setIsResponseStream()
lark.api.sendRequest(conf, req).then(resp => {
fs.writeFileSync("./test.0.png", resp.data)
console.log(resp.getRequestID())
console.log(resp.getHTTPStatusCode())
console.log(resp.getHeader())
}).catch(e => {
console.error(e)
})
let req2 = lark.api.newRequest("image/v4/get", "GET", lark.api.AccessTokenType.Tenant, undefined)
req2.setQueryParams(queryParams)
req2.setResponseStream(fs.createWriteStream("./test.1.png"))
lark.api.sendRequest(conf, req2).then(resp => {
console.log(resp.getRequestID())
console.log(resp.getHTTPStatusCode())
console.log(resp.getHeader())
}).catch(e => {
console.error(e)
})