com.files.FilesClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of files-sdk Show documentation
Show all versions of files-sdk Show documentation
The Files.com Java client library provides convenient access to the Files.com API from JVM based applications.
package com.files;
import com.fasterxml.jackson.core.type.TypeReference;
import com.files.models.ModelInterface;
import com.files.models.Session;
import com.files.net.FilesApiInterface;
import com.files.net.FilesOkHttpApi;
import com.files.net.FilesResponse;
import com.files.net.HttpMethods;
import com.files.net.HttpMethods.RequestMethods;
import com.files.util.FilesInputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import okhttp3.ConnectionPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class FilesClient {
private static final Logger log = LoggerFactory.getLogger(FilesClient.class);
private static final FilesApiInterface filesApi = new FilesOkHttpApi();
public static String apiKey;
public static Session session;
public static ConnectionPool httpPool = new ConnectionPool(FilesConfig.getInstance().getUpstreamMaxConnections(), FilesConfig.getInstance().getUpstreamTimeout(), TimeUnit.MILLISECONDS);
public static FilesResponse apiRequest(String url, HttpMethods.RequestMethods requestType, HashMap parameters, HashMap options) throws RuntimeException {
return filesApi.apiRequest(url, requestType, parameters, options);
}
public static ListIterator requestList(String url, RequestMethods requestType, TypeReference> className, HashMap parameters, HashMap options) throws RuntimeException {
return filesApi.apiRequestList(url, requestType, className, parameters, options);
}
public static T requestItem(String url, RequestMethods requestType, TypeReference className, HashMap parameters, HashMap options) throws RuntimeException {
final T item = filesApi.apiRequestItem(url, requestType, className, parameters, options);
if (item instanceof ModelInterface) {
((ModelInterface) item).setOptions(options);
}
return item;
}
public static FilesInputStream getFileInputStream(String url, long start, long end) throws IOException {
return filesApi.getFileInputStream(url, start, end);
}
public static long putBuffer(String url, RequestMethods requestType, String name, byte[] buffer, long length) throws IOException {
return filesApi.putBuffer(url, requestType, name, buffer, length);
}
public static long putBufferedInputStream(String url, RequestMethods requestType, String name, BufferedInputStream inputStream, long length) throws IOException {
return filesApi.putBufferedInputStream(url, requestType, name, inputStream, length);
}
public static void setProperty(String property, String value) {
FilesConfig.getInstance().setProperty(property, value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy