1 package eu
.alefzero
.webdav
; 
   4 import java
.io
.FileInputStream
; 
   5 import java
.io
.IOException
; 
   6 import java
.io
.InputStream
; 
   7 import java
.io
.OutputStream
; 
   9 import org
.apache
.commons
.httpclient
.methods
.RequestEntity
; 
  11 import eu
.alefzero
.owncloud
.files
.interfaces
.OnDatatransferProgressListener
; 
  14  * A RequestEntity that represents a File. 
  17 public class FileRequestEntity 
implements RequestEntity 
{ 
  20     final String contentType
; 
  21     OnDatatransferProgressListener listener
; 
  23     public FileRequestEntity(final File file
, final String contentType
) { 
  26             throw new IllegalArgumentException("File may not be null"); 
  29         this.contentType 
= contentType
; 
  32     public long getContentLength() { 
  33         return this.file
.length(); 
  36     public String 
getContentType() { 
  37         return this.contentType
; 
  40     public boolean isRepeatable() { 
  44     public void setOnDatatransferProgressListener(OnDatatransferProgressListener listener
) { 
  45         this.listener 
= listener
; 
  48     public void writeRequest(final OutputStream out
) throws IOException 
{ 
  49         byte[] tmp 
= new byte[4096]; 
  51         InputStream instream 
= new FileInputStream(this.file
); 
  53             while ((i 
= instream
.read(tmp
)) >= 0) { 
  56                     listener
.transferProgress(i
);