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

org.infinispan.client.rest.impl.okhttp.FileRestEntityOkHttp Maven / Gradle / Ivy

There is a newer version: 14.0.33.Final
Show newest version
package org.infinispan.client.rest.impl.okhttp;

import java.io.File;

import org.infinispan.client.rest.RestEntity;
import org.infinispan.commons.dataconversion.MediaType;

import okhttp3.RequestBody;

/**
 * @author Tristan Tarrant <[email protected]>
 * @since 10.0
 **/
public class FileRestEntityOkHttp implements RestEntity, RestEntityAdaptorOkHttp {
   private final MediaType contentType;
   private final File file;

   public FileRestEntityOkHttp(MediaType contentType, File file) {
      this.contentType = contentType;
      this.file = file;
   }

   @Override
   public String getBody() {
      throw new UnsupportedOperationException();
   }

   @Override
   public MediaType contentType() {
      return contentType;
   }

   @Override
   public RequestBody toRequestBody() {
      return RequestBody.create(okhttp3.MediaType.get(contentType.toString()), file);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy