@larksuiteoapi/node-sdk 1.33.1 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/README.zh.md +14 -0
- package/es/index.js +1213 -138
- package/lib/index.js +1213 -138
- package/package.json +1 -1
- package/types/index.d.ts +1414 -297
package/README.md
CHANGED
|
@@ -180,6 +180,20 @@ const resp = await client.im.file.get({
|
|
|
180
180
|
});
|
|
181
181
|
await resp.writeFile(`filepath.suffix`);
|
|
182
182
|
````
|
|
183
|
+
If you want to customize the processing of the stream, you can call the getReadableStream method to obtain the stream, such as writing the stream to a file:
|
|
184
|
+
```typescript
|
|
185
|
+
import * as fs from 'fs';
|
|
186
|
+
|
|
187
|
+
const resp = await client.im.file.get({
|
|
188
|
+
path: {
|
|
189
|
+
file_key: 'file key',
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
const readableStream = resp.getReadableStream();
|
|
193
|
+
const writableStream = fs.createWriteStream('file url');
|
|
194
|
+
readableStream.pipe(writableStream);
|
|
195
|
+
```
|
|
196
|
+
> Note: The stream can only be consumed once, if writeFile is used to consume the stream, getReadableStream will report an error when obtaining the stream/the obtained stream is empty; If you need to consume multiple streams, you can use getReadableStream to obtain the stream, then read the data in the stream for caching, and use the cached data to the consumer.
|
|
183
197
|
|
|
184
198
|
#### Normal call
|
|
185
199
|
Some old versions of the open interface cannot generate corresponding semantic calling methods, and you need to use the request method on the client to make manual calls:
|
package/README.zh.md
CHANGED
|
@@ -179,6 +179,20 @@ const resp = await client.im.file.get({
|
|
|
179
179
|
});
|
|
180
180
|
await resp.writeFile(`filepath.suffix`);
|
|
181
181
|
```
|
|
182
|
+
如果想要自定义对流的处理,可以调用getReadableStream方法获取到流,如将流写入文件:
|
|
183
|
+
```typescript
|
|
184
|
+
import * as fs from 'fs';
|
|
185
|
+
|
|
186
|
+
const resp = await client.im.file.get({
|
|
187
|
+
path: {
|
|
188
|
+
file_key: 'file key',
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
const readableStream = resp.getReadableStream();
|
|
192
|
+
const writableStream = fs.createWriteStream('file url');
|
|
193
|
+
readableStream.pipe(writableStream);
|
|
194
|
+
```
|
|
195
|
+
> 注意:流只能被消费一次,即如果使用了writeFile消费了流,则getReadableStream获取流会报错/获取到的流为空;如需消费多次流,可以使用getReadableStream获取流,然后读取流中的数据做缓存,将缓存的数据给消费方使用。
|
|
182
196
|
|
|
183
197
|
#### 普通调用
|
|
184
198
|
某些老版本的开放接口,无法生成对应的语义化调用方法,需要使用client上的request方法来进行手动调用:
|