package com.sz.admin.monitor.utils;

import java.io.File;

/**
 * ClassName: UrlConvert
 * Package: com.sz.admin.monitor.utils
 * Description:
 */
public class UrlConvert {
    private static final String RESOURCE_PREFIX = "/save/";
    /**
     * 将本地绝对路径转换为网络相对路径
     * @param localPath D:\work\sz-admin\images\test.jpg
     * @return /save/test.jpg
     */
    public static String convertToUrl(String localPath) {
        if (localPath == null || localPath.isEmpty()) {
            return null;
        }
        String fileName = new File(localPath).getName();
        // 2. 拼接映射前缀
        return RESOURCE_PREFIX + fileName;
    }
}
