24 lines
902 B
TypeScript
24 lines
902 B
TypeScript
import dayjs from "dayjs";
|
|
import api from "@/request";
|
|
|
|
export const generateSimpleObjectName = (fileName: string, parentDir?: String): string => {
|
|
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
const r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
return v.toString(16);
|
|
});
|
|
let objectName = parentDir + dayjs().format('/YYYY/MM/DD/') + uuid.replace(/-/g, '');
|
|
console.log(fileName,objectName,'4444')
|
|
if (fileName && fileName.length > 0) {
|
|
objectName += fileName.substring(fileName.lastIndexOf('.'))
|
|
}
|
|
console.log(objectName,'888')
|
|
return objectName;
|
|
}
|
|
|
|
export const getResignedObjectUrl = async (bucketName: string, objectName: string): Promise<string> => {
|
|
return (await api.get<string>('/common/getResignedObjectUrl', {
|
|
bucketName,
|
|
objectName
|
|
})).data as string;
|
|
}
|