FileSponge/src/main/lombok/org/warp/filesponge/api/FileAccessor.java

58 lines
1.7 KiB
Java
Raw Normal View History

2020-09-23 22:45:55 +02:00
/*
* FileSponge
* Copyright (C) 2020 Andrea Cavalli
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2020-09-23 23:58:54 +02:00
package org.warp.filesponge.api;
2020-09-23 22:45:55 +02:00
2021-01-11 14:40:31 +01:00
import java.nio.ByteBuffer;
2020-09-24 00:09:22 +02:00
import org.jetbrains.annotations.NotNull;
2020-09-24 11:59:46 +02:00
import org.warp.filesponge.value.FileStatus;
import org.warp.filesponge.value.FileURI;
2021-01-11 01:29:53 +01:00
import reactor.core.publisher.Mono;
2020-09-23 22:45:55 +02:00
2020-09-24 11:31:52 +02:00
/**
* FileAccessor can be used to access files from the client side
*/
2021-01-11 14:40:31 +01:00
public interface FileAccessor<FURI extends FileURI> {
2020-09-24 00:09:22 +02:00
2020-09-24 11:44:52 +02:00
/**
* Request file deletion
2020-09-24 11:51:41 +02:00
*
2020-09-24 11:44:52 +02:00
* @param fileURI File URI
2021-01-11 01:29:53 +01:00
* @return Empty.
2020-09-24 11:44:52 +02:00
*/
2021-01-11 01:29:53 +01:00
Mono<Void> delete(@NotNull FURI fileURI);
2020-09-24 00:09:22 +02:00
2020-09-24 11:44:52 +02:00
/**
* Get file content
2020-09-24 11:51:41 +02:00
*
* @param fileURI File URI
2020-09-24 11:44:52 +02:00
* @param offlineOnly true to get the file from cache
2021-01-11 01:29:53 +01:00
* @return content if found. If the request is offline the future will complete instantly.
* Can be empty
2020-09-24 11:44:52 +02:00
*/
2021-01-11 14:40:31 +01:00
Mono<ByteBuffer> getContent(@NotNull FURI fileURI, boolean offlineOnly);
2020-09-24 00:09:22 +02:00
2020-09-24 11:44:52 +02:00
/**
* Get file status
2020-09-24 11:51:41 +02:00
*
2020-09-24 11:44:52 +02:00
* @param fileURI File URI
2021-01-11 01:29:53 +01:00
* @return status of this file. Cannot be empty.
2020-09-24 11:44:52 +02:00
*/
2021-01-11 01:29:53 +01:00
Mono<FileStatus> getStatus(@NotNull FURI fileURI);
2020-09-23 22:45:55 +02:00
}