All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.getstream.client.ImageStorageClient Maven / Gradle / Ivy

There is a newer version: 3.15.0
Show newest version
package io.getstream.client;

import static io.getstream.core.utils.Auth.buildFilesToken;

import io.getstream.core.StreamImages;
import io.getstream.core.exceptions.StreamException;
import io.getstream.core.http.Token;
import io.getstream.core.options.Crop;
import io.getstream.core.options.Resize;
import io.getstream.core.utils.Auth.TokenAction;
import java.io.File;
import java.net.URL;
import java8.util.concurrent.CompletableFuture;

public final class ImageStorageClient {
  private final String secret;
  private final StreamImages images;

  ImageStorageClient(String secret, StreamImages images) {
    this.secret = secret;
    this.images = images;
  }

  public CompletableFuture upload(String fileName, byte[] content) throws StreamException {
    final Token token = buildFilesToken(secret, TokenAction.WRITE);
    return images.upload(token, fileName, content);
  }

  public CompletableFuture upload(File content) throws StreamException {
    final Token token = buildFilesToken(secret, TokenAction.WRITE);
    return images.upload(token, content);
  }

  public CompletableFuture delete(URL url) throws StreamException {
    final Token token = buildFilesToken(secret, TokenAction.DELETE);
    return images.delete(token, url);
  }

  public CompletableFuture process(URL url, Crop crop) throws StreamException {
    final Token token = buildFilesToken(secret, TokenAction.READ);
    return images.process(token, url, crop);
  }

  public CompletableFuture process(URL url, Resize resize) throws StreamException {
    final Token token = buildFilesToken(secret, TokenAction.READ);
    return images.process(token, url, resize);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy