package com.netfever.web.storage.datasources;
import java.io.File;
import java.io.FileInputStream;
import java.nio.channels.FileChannel;
import com.netfever.web.storage.api.IWebStream;
import com.netfever.web.storage.api.StorageException;
public class LocalWebStream implements IWebStream {
private String mime;
private File file;
public LocalWebStream(String mime, File file) {
super();
this.mime = mime;
this.file = file;
}
@Override
public String getMime() {
return this.mime;
}
@Override
public FileChannel openChannel() throws StorageException {
try {
return new FileInputStream(this.file).getChannel();
} catch (Exception e) {
throw new StorageException(e.getMessage(), e);
}
}
@Override
public int getLength() {
return (int)this.file.length();
}
}