Skip to content

Commit

Permalink
Fix downloadFile failed error #5, if failed ignore that file.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Oct 25, 2023
1 parent 93e494b commit 6a6f542
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions feishu-pages/src/feishu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ export const feishuFetch = async (method, path, payload): Promise<any> => {

/**
* Download Feishu File into a Local path
*
* If download failed, return null
*
* @param fileToken
* @param localPath
* @returns
Expand Down Expand Up @@ -238,6 +241,10 @@ export const feishuDownload = async (fileToken: string, localPath: string) => {
});
}

if (!res) {
return null;
}

if (res.data) {
let extension = mime.extension(res.headers['content-type']);
console.info(
Expand Down
4 changes: 4 additions & 0 deletions feishu-pages/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ const downloadFiles = async (
fileToken,
path.join(path.join(docFolder, 'assets'), fileToken)
);
if (!filePath) {
continue;
}

const extension = path.extname(filePath);

const re = new RegExp(`${fileToken}`, 'gm');
Expand Down

0 comments on commit 6a6f542

Please sign in to comment.