001/**
002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com).
003 * <p>
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * <p>
008 * http://www.apache.org/licenses/LICENSE-2.0
009 * <p>
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package io.jboot.web.attachment;
018
019import java.io.File;
020import java.io.InputStream;
021
022/**
023 * @author michael yang (fuhai999@gmail.com)
024 */
025public interface AttachmentContainer {
026
027    /**
028     * 保存文件
029     *
030     * @param file
031     * @return 返回文件的相对路径
032     */
033    String saveFile(File file);
034
035
036    /**
037     * 保存文件
038     *
039     * @param file
040     * @return 返回文件的相对路径
041     */
042    String saveFile(File file, String toRelativePath);
043
044    /**
045     * 保存文件
046     *
047     * @param inputStream
048     * @return
049     */
050    String saveFile(InputStream inputStream, String toRelativePath);
051
052
053    /**
054     * 删除文件
055     *
056     * @param relativePath
057     * @return
058     */
059    boolean deleteFile(String relativePath);
060
061
062    /**
063     * 通过相对路径获取文件
064     *
065     * @param relativePath
066     * @return
067     */
068    File getFile(String relativePath);
069
070
071    /**
072     * 通过一个文件,获取其相对路径
073     *
074     * @param file
075     * @return
076     */
077    String getRelativePath(File file);
078
079
080}