|
@@ -3,6 +3,7 @@ import { ILogger, Init, Inject, Provide } from '@midwayjs/core';
|
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
|
import { OpenUserEntity } from '../entity/open_user';
|
|
|
import * as crypto from 'crypto';
|
|
|
+import * as fs from 'fs';
|
|
|
import { LessThan, QueryRunner, Repository } from 'typeorm';
|
|
|
import {
|
|
|
OpenPaymentOrderEntity,
|
|
@@ -366,14 +367,17 @@ export class EasyOpenService extends BaseService {
|
|
|
// 生成 OSS 存储路径(带原始文件名)
|
|
|
const ossPath = `fusion/uploads/${Date.now()}_${file.filename}`;
|
|
|
// const result = await this.ossService.put('/test/test.log', localFile);
|
|
|
-
|
|
|
- // 使用临时文件路径上传
|
|
|
- const result = await this.ossService.put(
|
|
|
- ossPath,
|
|
|
- file.data, // 直接使用 file.data 作为路径
|
|
|
- // 如果需要设置 headers 可以添加第三个参数
|
|
|
- { headers: { 'Content-Type': file.mimeType } }
|
|
|
- );
|
|
|
+ const fileContent = typeof file.data === 'string' ? fs.readFileSync(file.data) : file.data;
|
|
|
+ const result = await this.ossService.put(ossPath, fileContent, {
|
|
|
+ headers: { 'Content-Type': file.mimeType },
|
|
|
+ });
|
|
|
+ // // 使用临时文件路径上传
|
|
|
+ // const result = await this.ossService.put(
|
|
|
+ // ossPath,
|
|
|
+ // file.data, // 直接使用 file.data 作为路径
|
|
|
+ // // 如果需要设置 headers 可以添加第三个参数
|
|
|
+ // { headers: { 'Content-Type': file.mimeType } }
|
|
|
+ // );
|
|
|
console.log(file.data);
|
|
|
// await unlinkSync(file.data);
|
|
|
|
|
@@ -383,7 +387,9 @@ export class EasyOpenService extends BaseService {
|
|
|
originalName: file.filename,
|
|
|
size: file.size,
|
|
|
};
|
|
|
- } catch (e) {}
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 获取商户信息
|