Skip to content

Commit

Permalink
offline file forward
Browse files Browse the repository at this point in the history
  • Loading branch information
takayama-lily committed Jun 21, 2022
1 parent 331a8ca commit 0c1a4dc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/friend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,11 @@ export class Friend extends User {
* @param callback 监控上传进度的回调函数,拥有一个"百分比进度"的参数
* @returns 文件id(撤回时使用)
*/
async sendFile(file: string | Buffer, filename?: string, callback?: (percentage: string) => void) {
async sendFile(file: string | Buffer | Uint8Array, filename?: string, callback?: (percentage: string) => void) {
let filesize: number, filemd5: Buffer, filesha: Buffer, filestream: Readable
if (file instanceof Buffer) {
if (file instanceof Uint8Array) {
if (!Buffer.isBuffer(file))
file = Buffer.from(file)
filesize = file.length
filemd5 = md5(file), filesha = sha(file)
filename = filename ? String(filename) : ("file" + filemd5.toString("hex"))
Expand Down

0 comments on commit 0c1a4dc

Please sign in to comment.