io.getstream.client.FileStorageClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stream-java Show documentation
Show all versions of stream-java Show documentation
Stream Feeds Java Client for backend and android integrations
package io.getstream.client;
import static io.getstream.core.utils.Auth.buildFilesToken;
import io.getstream.core.StreamFiles;
import io.getstream.core.exceptions.StreamException;
import io.getstream.core.http.Token;
import io.getstream.core.utils.Auth.TokenAction;
import java.io.File;
import java.net.URL;
import java8.util.concurrent.CompletableFuture;
public final class FileStorageClient {
private final String secret;
private final StreamFiles files;
FileStorageClient(String secret, StreamFiles files) {
this.secret = secret;
this.files = files;
}
public CompletableFuture upload(String fileName, byte[] content) throws StreamException {
final Token token = buildFilesToken(secret, TokenAction.WRITE);
return files.upload(token, fileName, content);
}
public CompletableFuture upload(File content) throws StreamException {
final Token token = buildFilesToken(secret, TokenAction.WRITE);
return files.upload(token, content);
}
public CompletableFuture delete(URL url) throws StreamException {
final Token token = buildFilesToken(secret, TokenAction.DELETE);
return files.delete(token, url);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy