fix: 小程序不检查10M限制,默认超时时间设置为1小时

This commit is contained in:
Pan Qiancheng 2025-12-26 17:33:37 +08:00
parent 95b506b0eb
commit f3d782fcbc
9 changed files with 6 additions and 10 deletions

View File

@ -109,7 +109,7 @@ export default class ALiYunBackend extends ALiYun {
// 大部分校验都在formUploadMeta中完成这里可以不多做判断了
const b = aliyunCosConfig.buckets.find((ele) => ele.name === extraFile.bucket);
const preInit = await instance.prepareMultipartUpload(extraFile.bucket, b.zone, key, extraFile.chunkInfo?.partCount, {
timeout: 30000,
timeout: 1 * 60 * 60 * 1000, // 1 hour
...(useSts ? stsInfo
: {}),
});

View File

@ -100,7 +100,7 @@ export default class S3Backend extends S3 {
const { instance, config: s3Config } = this.getConfigAndInstance(application, extraFile.bucket);
const preInit = await instance.prepareMultipartUpload(extraFile.bucket, key, extraFile.chunkInfo?.partCount, {
endpoint: s3Config.endpoint,
expiresIn: 30000, // 上传链接过期时间,单位秒
expiresIn: 1 * 60 * 60 * 1000, // 1 hour
});
return {
uploadId: preInit.uploadId,

View File

@ -24,7 +24,6 @@ export async function sliceFile(file, chunkSize, partCount) {
export async function sliceFileForMp(filePath, chunkSize, partCount) {
const fs = wx.getFileSystemManager();
const tempDir = `${wx.env.USER_DATA_PATH}/oak_upload_temp`;
assert(chunkSize <= 10 * 1024 * 1024, '小程序下,单个分片大小不能超过 10MB'); // 微信小程序限制单个文件不能超过10MB
// 确保临时目录存在
try {
fs.accessSync(tempDir);

View File

@ -112,7 +112,7 @@ class ALiYunBackend extends aliyun_1.default {
// 大部分校验都在formUploadMeta中完成这里可以不多做判断了
const b = aliyunCosConfig.buckets.find((ele) => ele.name === extraFile.bucket);
const preInit = await instance.prepareMultipartUpload(extraFile.bucket, b.zone, key, extraFile.chunkInfo?.partCount, {
timeout: 30000,
timeout: 1 * 60 * 60 * 1000, // 1 hour
...(useSts ? stsInfo
: {}),
});

View File

@ -103,7 +103,7 @@ class S3Backend extends s3_1.default {
const { instance, config: s3Config } = this.getConfigAndInstance(application, extraFile.bucket);
const preInit = await instance.prepareMultipartUpload(extraFile.bucket, key, extraFile.chunkInfo?.partCount, {
endpoint: s3Config.endpoint,
expiresIn: 30000, // 上传链接过期时间,单位秒
expiresIn: 1 * 60 * 60 * 1000, // 1 hour
});
return {
uploadId: preInit.uploadId,

View File

@ -30,7 +30,6 @@ async function sliceFile(file, chunkSize, partCount) {
async function sliceFileForMp(filePath, chunkSize, partCount) {
const fs = wx.getFileSystemManager();
const tempDir = `${wx.env.USER_DATA_PATH}/oak_upload_temp`;
(0, assert_1.default)(chunkSize <= 10 * 1024 * 1024, '小程序下,单个分片大小不能超过 10MB'); // 微信小程序限制单个文件不能超过10MB
// 确保临时目录存在
try {
fs.accessSync(tempDir);

View File

@ -187,7 +187,7 @@ export default class ALiYunBackend
key,
extraFile.chunkInfo?.partCount!,
{
timeout: 30000,
timeout: 1 * 60 * 60 * 1000, // 1 hour
...(useSts ? stsInfo
: {}),
}

View File

@ -190,7 +190,7 @@ export default class S3Backend extends S3 implements CosBackend<EntityDict> {
extraFile.chunkInfo?.partCount!,
{
endpoint: s3Config.endpoint,
expiresIn: 30000, // 上传链接过期时间,单位秒
expiresIn: 1 * 60 * 60 * 1000, // 1 hour
}
)

View File

@ -33,8 +33,6 @@ export async function sliceFileForMp(filePath: string, chunkSize: number, partCo
const fs = wx.getFileSystemManager();
const tempDir = `${wx.env.USER_DATA_PATH}/oak_upload_temp`;
assert(chunkSize <= 10 * 1024 * 1024, '小程序下,单个分片大小不能超过 10MB'); // 微信小程序限制单个文件不能超过10MB
// 确保临时目录存在
try {
fs.accessSync(tempDir);