package com.xingxi.common.aliyun.oss;

import com.aliyun.oss.model.CannedAccessControlList;
import com.aliyun.oss.model.OSSObject;

import java.io.InputStream;

public interface AliyunOSSClient {

    /**
     * 桶子不存在就创建
     * @param bucketName
     * @throws Exception
     */
    void createBucket(String bucketName) throws Exception;

    /**
     * 上传文件
     * @param bucketName
     * @param objectName
     * @param inputStream
     * @return
     * @throws Exception
     */
    String putObject(String bucketName, String objectName, InputStream inputStream) throws Exception;

    /**
     * 上传文件
     * @param bucketName
     * @param objectName
     * @param inputStream
     * @param cannedAccessControlList
     * @return
     * @throws Exception
     */
    String putObject(String bucketName, String objectName, InputStream inputStream, CannedAccessControlList cannedAccessControlList) throws Exception;

    /**
     * 默认上传default bucket
     * @param objectName
     * @param inputStream
     * @return
     * @throws Exception
     */
    String putObject(String objectName, InputStream inputStream) throws Exception;


    /**
     * 默认上传default bucket
     * @param objectName
     * @param inputStream
     * @param cannedAccessControlList
     * @return
     * @throws Exception
     */
    String putObject(String objectName, InputStream inputStream, CannedAccessControlList cannedAccessControlList) throws Exception;

    /**
     * 取得对象
     * @param bucketName
     * @param objectName
     * @return
     * @throws Exception
     */
    OSSObject getObject(String bucketName, String objectName) throws Exception;



    // 文件是否存在
    boolean doesObjectExist(String objectName) throws Exception;

    
    /**
     * 取得默认桶子中的对象
     * @param objectName
     * @return
     * @throws Exception
     */
    OSSObject getObject(String objectName) throws Exception;

    /**
     * 删除文件
     * @param bucketName
     * @param objectName
     * @throws Exception
     */
    void removeObject(String bucketName, String objectName) throws Exception;

    /**
     * 取得配置
     * @return
     */
    AliyunOSSProfile getProfile();
}
