/* Copyright [2020] [https://www.xiaonuo.vip] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: 1.请不要删除和修改根目录下的LICENSE文件。 2.请不要删除和修改Snowy源码头部的版权声明。 3.请保留源码和相关描述文件的项目出处,作者声明等。 4.分发源码时候,请注明软件出处 https://gitee.com/xiaonuobase/snowy 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/xiaonuobase/snowy 6.若您的项目无法满足以上几点,可申请商业授权,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip */ package vip.xiaonuo.core.file; import vip.xiaonuo.core.file.common.enums.BucketAuthEnum; import java.io.InputStream; /** * 文件操纵者(内网操作) *

* 如果存在未包含的操作,可以调用getClient()自行获取client进行操作 * * @author xuyuxiang * @date 2018-06-27-下午12:37 */ public interface FileOperator { /** * 初始化操作的客户端 * * @author xuyuxiang * @date 2020/5/23 2:32 下午 */ void initClient(); /** * 销毁操作的客户端 * * @author xuyuxiang * @date 2020/5/23 2:32 下午 */ void destroyClient(); /** * 获取操作的客户端 * * @author xuyuxiang * @date 2020/5/23 2:58 下午 */ Object getClient(); /** * 查询存储桶是否存在 *

* 例如:传入参数examplebucket-1250000000,返回true代表存在此桶 * * @author xuyuxiang * @date 2020/5/23 2:29 下午 */ boolean doesBucketExist(String bucketName); /** * 设置预定义策略 *

* 预定义策略如公有读、公有读写、私有读 * * @author xuyuxiang * @date 2020/5/23 3:02 下午 */ void setBucketAcl(String bucketName, BucketAuthEnum bucketAuthEnum); /** * 判断是否存在文件 * * @param bucketName 桶名称 * @param key 唯一标示id,例如a.txt, doc/a.txt * @author xuyuxiang * @date 2018/6/27 下午1:14 */ boolean isExistingFile(String bucketName, String key); /** * 存储文件 * * @param bucketName 桶名称 * @param key 唯一标示id,例如a.txt, doc/a.txt * @param bytes 文件字节数组 * @author xuyuxiang * @date 2018/6/27 下午1:16 */ void storageFile(String bucketName, String key, byte[] bytes); /** * 存储文件(存放到指定的bucket里边) * * @param bucketName 桶名称 * @param key 唯一标示id,例如a.txt, doc/a.txt * @param inputStream 文件流 * @author xuyuxiang * @date 2018年10月19日13:20:37 */ void storageFile(String bucketName, String key, InputStream inputStream); /** * 获取某个bucket下的文件字节 * * @param bucketName 桶名称 * @param key 唯一标示id,例如a.txt, doc/a.txt * @author xuyuxiang * @date 2018/6/27 下午1:15 */ byte[] getFileBytes(String bucketName, String key); /** * 文件访问权限管理 * * @param bucketName 桶名称 * @param key 唯一标示id,例如a.txt, doc/a.txt * @param bucketAuthEnum 文件权限 * @author xuyuxiang * @date 2020/5/23 5:30 下午 */ void setFileAcl(String bucketName, String key, BucketAuthEnum bucketAuthEnum); /** * 拷贝文件 * * @param originBucketName 源文件桶 * @param originFileKey 源文件名称 * @param newBucketName 新文件桶 * @param newFileKey 新文件名称 * @author xuyuxiang * @date 2020/5/23 6:09 下午 */ void copyFile(String originBucketName, String originFileKey, String newBucketName, String newFileKey); /** * 获取文件的下载地址(带鉴权的),生成外网地址 * * @param bucketName 文件桶 * @param key 文件唯一标识 * @author xuyuxiang * @date 2018/7/7 上午11:27 */ String getFileAuthUrl(String bucketName, String key, Long timeoutMillis); /** * 删除文件 * * @param bucketName 文件桶 * @param key 文件唯一标识 * @author xuyuxiang * @date 2020/9/18 */ void deleteFile(String bucketName, String key); }