wupengfei
2025-07-30 5d3529a43c2f80c6eff5235c646a446737dcb13c
src/utils/common/file.ts
@@ -8,12 +8,17 @@
  return _url.startsWith('/') ? _url : '/' + _url;
}
type ConvertApi2FormUrlOptions = {
  fileName?: string;
};
/**
 * 把api返回的路径转换为upload的路径
 */
export function convertApi2FormUrl(path: string) {
export function convertApi2FormUrl(path: string, options: ConvertApi2FormUrlOptions = {}) {
  const { fileName } = options;
  return {
    name: setOssFileName(path),
    name: fileName ? fileName : setOssFileName(path),
    path: urlOmitDomain(path),
    url: setOSSLink(path),
    status: 'success',
@@ -21,8 +26,8 @@
  } as UploadUserFile;
}
export function convertApi2FormUrlOnlyOne(path: string) {
  return path ? [convertApi2FormUrl(path)] : [];
export function convertApi2FormUrlOnlyOne(path: string, options: ConvertApi2FormUrlOptions = {}) {
  return path ? [convertApi2FormUrl(path, options)] : [];
}
/**