|
@@ -14,7 +14,7 @@ const ALI_OSS_BUCKET = process.env.ALI_OSS_BUCKET || "hep-textbook"
|
|
|
const ALI_OSS_ACCESS_KEY_ID = process.env.ALI_OSS_ACCESS_KEY_ID || "LTAI5t6AbTiAvXmeoVdJZhL3"
|
|
|
const ALI_OSS_ACCESS_KEY_SECRET = process.env.ALI_OSS_ACCESS_KEY_SECRET || "KLtQRdIW69KLP7jnzHNUf7eKmdptxH"
|
|
|
|
|
|
-async function uploadFileToOSS(filePath){
|
|
|
+export async function uploadFileToOSS(filePath){
|
|
|
let client = new OSS({
|
|
|
// yourRegion填写Bucket所在地域。以华东1(杭州)为例,yourRegion填写为oss-cn-hangzhou。
|
|
|
region: "oss-cn-beijing",
|
|
@@ -31,7 +31,7 @@ async function uploadFileToOSS(filePath){
|
|
|
console.log('put success: %j', r1);
|
|
|
return r1
|
|
|
}
|
|
|
-function getFileName(filePath) {
|
|
|
+export function getFileName(filePath) {
|
|
|
// 使用 '/' 或 '\' 作为分隔符,分割路径
|
|
|
const parts = filePath.split(/[/\\]/);
|
|
|
// 返回最后一个部分,即文件名
|
|
@@ -44,7 +44,7 @@ module.exports.uploadFileToOSS = uploadFileToOSS
|
|
|
* @param {Array<string>} filePathList - 要打包的文件路径数组
|
|
|
* @param {string} outputZipName - 输出的zip文件名称
|
|
|
*/
|
|
|
- function createZip(filePathList, outputZipName) {
|
|
|
+ export function createZip(filePathList, outputZipName) {
|
|
|
let zipStream = new compressing.zip.Stream();
|
|
|
return new Promise((resolve)=>{
|
|
|
try {
|
|
@@ -97,7 +97,7 @@ module.exports.createZip = createZip
|
|
|
* @param {string} outputPath - 输出 PDF 文件的路径
|
|
|
* @returns {Promise<void>}
|
|
|
*/
|
|
|
- async function docsToPdf(docxPath, outputPath) {
|
|
|
+ export async function docsToPdf(docxPath, outputPath) {
|
|
|
try {
|
|
|
const files = [docxPath];
|
|
|
|
|
@@ -141,7 +141,7 @@ module.exports.docsToPdf = docsToPdf
|
|
|
}
|
|
|
replaceDocx(inputDocx, outputDocx, replaceData)
|
|
|
*/
|
|
|
-function replaceDocx(inputDocxPath, outputDocxPath, options,eventMap) {
|
|
|
+export function replaceDocx(inputDocxPath, outputDocxPath, options,eventMap) {
|
|
|
return new Promise((resolve,reject)=>{
|
|
|
|
|
|
// 解压出来的临时目录
|