package com.jeequan.jeepay.components.oss.service;

import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.components.oss.constant.OssSavePlaceEnum;
import com.jeequan.jeepay.components.oss.model.OssFileConfig;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

/**
 * OSSService 接口
 *
 * @author terrfly
 * @date 2021/7/12 18:18
 */
public interface IOssService {

    @Data
    class UploadFormParams{

        private String formActionUrl;
        private String ossFileUrl;
        private JSONObject formParams;
    }

    /** 上传文件 & 生成下载/预览URL **/
    String upload2PreviewUrl(OssSavePlaceEnum ossSavePlaceEnum, MultipartFile multipartFile, String saveDirAndFileName);

    /** 生成上传form表单的参数 **/
    UploadFormParams genFormParams(String bizType, OssFileConfig ossFileConfig, String saveDirAndFileName);

    /** 将文件下载到本地
     * 返回是否 写入成功
     * false: 写入失败， 或者文件不存在
     * **/
    boolean downloadFile(OssSavePlaceEnum ossSavePlaceEnum, String source, String target);

}
