package com.yx.face.boot.uitls;

/**
 * @ProjectName: face-server
 * @Package: com.yx.face.boot.uitls
 * @ClassName: FileUploadUtil
 * @Author: 崔哥
 * @Description: 文件上传
 * @Date: 2021/11/8 16:38
 * @Version: 1.0
 */
public class FileUploadUtil {

    private static final String url = "http://192.168.99.11:9810/winxin-fyzd/fyzd/file/";
//    private static final String url = "http://127.0.0.1:9810/winxin-fyzd/fyzd/file/";

    /**
     * 文件上传
     */
    public static String uploadUtil(String base64, String name) {

        String sync = OkHttpUtils.builder().url(url + "upload")
                // 有参数的话添加参数，可多个
                .addParam("base64", base64)
                .addParam("name", name)
                .post(true)
                .sync();
        return sync;
    }

    /**
     * 文件上传
     */
    public static String uploadLogImgUtil(String base64, String name) {

        String sync = OkHttpUtils.builder().url(url + "logImg")
                // 有参数的话添加参数，可多个
                .addParam("base64", base64)
                .addParam("name", name)
                .post(true)
                .sync();
        return sync;
    }

    /**
     * 文件下载
     */
    public static String downloadFile(String name) {
        String sync = OkHttpUtils.builder().url(url + "downLoad")
                // 有参数的话添加参数，可多个
                .addParam("fileName", name)
                .get()
                .sync();
        return sync;
    }
}
