policeSecurity/securityManagement/src/utils/minioUtil.ts

27 lines
813 B
TypeScript
Raw Normal View History

2024-08-30 18:01:34 +08:00
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;
}