policeSecurity/securityManagement/src/utils/minioUtil.ts

27 lines
813 B
TypeScript

import api from "@/axios";
import dayjs from "dayjs";
import {uuid} from "vue-uuid";
/**
* 生成一个简单的对象文件地址
* @param fileName 原始文件名
* @param parentDir 上级目录
*/
export const generateSimpleObjectName = (fileName: string, parentDir?: String): string => {
let objectName = parentDir + dayjs().format('/YYYY/MM/DD/') + uuid.v4().replace(/-/g, '');
if (fileName && fileName.length > 0) {
objectName += fileName.substring(fileName.lastIndexOf('.'))
}
return objectName;
}
/**
* 获取生成预签名的 URL
*/
export const getResignedObjectUrl = async (bucketName: string, objectName: string): Promise<string> => {
return (await api.get<string>('/common/getResignedObjectUrl', {
bucketName,
objectName
})).data as string;
}