package com.zhongshu.card.server.core.model.upLoadFile;

import com.zhongshu.card.server.core.model.upLoadFile.oss.SuperObjectStorage;

import java.io.InputStream;
import java.util.Collection;

/**
 * 对象存储
 */
public abstract class SuperObjectStorageStore {

    //账户名
    private String accountName;
    //配置信息
    private SuperObjectStorage objectStorage;

//    /**
//     * 实例化
//     */
//    public SuperObjectStorageStore(String accountName, SuperObjectStorage objectStorage) {
//        this.accountName = accountName;
//        this.objectStorage = objectStorage;
//    }

    public void setInfo(String accountName, SuperObjectStorage objectStorage) {
        this.accountName = accountName;
        this.objectStorage = objectStorage;
    }


    /**
     * 取出对象存储类型
     *
     * @return
     */
    public ObjectStorageType storageType() {
        return objectStorage.storageType();
    }


    /**
     * 获取临时密钥
     *
     * @return
     */
    public abstract StsToken getStsToken(Collection<String[]> path);


    /**
     * 如果文件存在，则获取对象链接
     *
     * @param path
     * @return
     */
    public abstract FileObject getFileObject(String[] path);


    /**
     * 上传文件对象
     *
     * @param path
     * @param inputStream
     */
    public abstract String[] uploadFileObject(String[] path, InputStream inputStream, Long length);


    /**
     * 删除文件对象
     *
     * @return
     */
    public abstract boolean deleteFileObject(String[] path);


    /**
     * 释放
     */
    public abstract void destroy();


    protected String getAccountName() {
        return accountName;
    }

    protected SuperObjectStorage getObjectStorage() {
        return objectStorage;
    }

}
