inleft
2022-02-09 9bcb19959eeb9da9bde2561e7278f6d0a55eb151
commit | author | age
9bcb19 1 /*
I 2 Copyright [2020] [https://www.xiaonuo.vip]
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8   http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
17
18 1.请不要删除和修改根目录下的LICENSE文件。
19 2.请不要删除和修改Snowy源码头部的版权声明。
20 3.请保留源码和相关描述文件的项目出处,作者声明等。
21 4.分发源码时候,请注明软件出处 https://gitee.com/xiaonuobase/snowy
22 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/xiaonuobase/snowy
23 6.若您的项目无法满足以上几点,可申请商业授权,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
24  */
25 package vip.xiaonuo.core.file;
26
27
28 import vip.xiaonuo.core.file.common.enums.BucketAuthEnum;
29
30 import java.io.InputStream;
31
32 /**
33  * 文件操纵者(内网操作)
34  * <p>
35  * 如果存在未包含的操作,可以调用getClient()自行获取client进行操作
36  *
37  * @author xuyuxiang
38  * @date 2018-06-27-下午12:37
39  */
40 public interface FileOperator {
41
42     /**
43      * 初始化操作的客户端
44      *
45      * @author xuyuxiang
46      * @date 2020/5/23 2:32 下午
47      */
48     void initClient();
49
50     /**
51      * 销毁操作的客户端
52      *
53      * @author xuyuxiang
54      * @date 2020/5/23 2:32 下午
55      */
56     void destroyClient();
57
58     /**
59      * 获取操作的客户端
60      *
61      * @author xuyuxiang
62      * @date 2020/5/23 2:58 下午
63      */
64     Object getClient();
65
66     /**
67      * 查询存储桶是否存在
68      * <p>
69      * 例如:传入参数examplebucket-1250000000,返回true代表存在此桶
70      *
71      * @author xuyuxiang
72      * @date 2020/5/23 2:29 下午
73      */
74     boolean doesBucketExist(String bucketName);
75
76     /**
77      * 设置预定义策略
78      * <p>
79      * 预定义策略如公有读、公有读写、私有读
80      *
81      * @author xuyuxiang
82      * @date 2020/5/23 3:02 下午
83      */
84     void setBucketAcl(String bucketName, BucketAuthEnum bucketAuthEnum);
85
86     /**
87      * 判断是否存在文件
88      *
89      * @param bucketName 桶名称
90      * @param key        唯一标示id,例如a.txt, doc/a.txt
91      * @author xuyuxiang
92      * @date 2018/6/27 下午1:14
93      */
94     boolean isExistingFile(String bucketName, String key);
95
96     /**
97      * 存储文件
98      *
99      * @param bucketName 桶名称
100      * @param key        唯一标示id,例如a.txt, doc/a.txt
101      * @param bytes      文件字节数组
102      * @author xuyuxiang
103      * @date 2018/6/27 下午1:16
104      */
105     void storageFile(String bucketName, String key, byte[] bytes);
106
107     /**
108      * 存储文件(存放到指定的bucket里边)
109      *
110      * @param bucketName  桶名称
111      * @param key         唯一标示id,例如a.txt, doc/a.txt
112      * @param inputStream 文件流
113      * @author xuyuxiang
114      * @date 2018年10月19日13:20:37
115      */
116     void storageFile(String bucketName, String key, InputStream inputStream);
117
118     /**
119      * 获取某个bucket下的文件字节
120      *
121      * @param bucketName 桶名称
122      * @param key        唯一标示id,例如a.txt, doc/a.txt
123      * @author xuyuxiang
124      * @date 2018/6/27 下午1:15
125      */
126     byte[] getFileBytes(String bucketName, String key);
127
128     /**
129      * 文件访问权限管理
130      *
131      * @param bucketName     桶名称
132      * @param key            唯一标示id,例如a.txt, doc/a.txt
133      * @param bucketAuthEnum 文件权限
134      * @author xuyuxiang
135      * @date 2020/5/23 5:30 下午
136      */
137     void setFileAcl(String bucketName, String key, BucketAuthEnum bucketAuthEnum);
138
139     /**
140      * 拷贝文件
141      *
142      * @param originBucketName 源文件桶
143      * @param originFileKey    源文件名称
144      * @param newBucketName    新文件桶
145      * @param newFileKey       新文件名称
146      * @author xuyuxiang
147      * @date 2020/5/23 6:09 下午
148      */
149     void copyFile(String originBucketName, String originFileKey, String newBucketName, String newFileKey);
150
151     /**
152      * 获取文件的下载地址(带鉴权的),生成外网地址
153      *
154      * @param bucketName 文件桶
155      * @param key        文件唯一标识
156      * @author xuyuxiang
157      * @date 2018/7/7 上午11:27
158      */
159     String getFileAuthUrl(String bucketName, String key, Long timeoutMillis);
160
161     /**
162      * 删除文件
163      *
164      * @param bucketName 文件桶
165      * @param key        文件唯一标识
166      * @author xuyuxiang
167      * @date 2020/9/18
168      */
169     void deleteFile(String bucketName, String key);
170
171 }