package de.ivu.elect.presentation.exchange.action;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.primefaces.model.file.UploadedFile;

public class ContentUploadedFile implements UploadedFile {

  private final String fileName;

  private final String contentType;

  private final byte[] content;

  public ContentUploadedFile(String fileName, String contentType, byte[] content) {
    this.fileName = fileName;
    this.contentType = contentType;
    this.content = content;
  }

  @Override
  public String getFileName() {
    return fileName;
  }

  @Override
  public InputStream getInputStream() throws IOException {
    return new ByteArrayInputStream(content);
  }

  @Override
  public byte[] getContent() {
    return content;
  }

  @Override
  public String getContentType() {
    return contentType;
  }

  @Override
  public long getSize() {
    return content.length;
  }

  @Override
  public void write(String filePath) throws Exception {
    // noop
  }

  @Override
  public void delete() throws IOException {
// noop
  }
}
